position

WebGL简易教程(四):颜色

匿名 (未验证) 提交于 2019-12-03 00:05:01
Ŀ¼ 在上一篇教程 《WebGL简易教程(三):绘制一个三角形(缓冲区对象)》 中,通过使用缓冲区对象(buffer object)来向顶点着色器传送数据。那么,如果这些数据(与顶点相关的数据,如法向量、颜色等)需要继续传送到片元着色器该怎么办呢? 例如这里给三角形的每个顶点赋予不同的颜色,绘制一个彩色的三角形。这个时候就需要用到之前( 《WebGL简易教程(二):向着色器传输数据》 )介绍过的varying变量了。 改进上一篇中绘制三角形(HelloTriangle.js)的代码: // 顶点着色器程序 var VSHADER_SOURCE = 'attribute vec4 a_Position;\n' + // attribute variable 'attribute vec4 a_Color;\n' + 'varying vec4 v_Color;\n' + 'void main() {\n' + ' gl_Position = a_Position;\n' + // Set the vertex coordinates of the point ' v_Color = a_Color;\n' + '}\n' ; // 片元着色器程序 var FSHADER_SOURCE = 'precision mediump float;\n' + 'varying vec4 v

vue

匿名 (未验证) 提交于 2019-12-03 00:02:01
vue-baidu-map 官网地址: https://dafrok.github.io/vue-baidu-map/#/zh/index 记录一下在vue中使用npm下载使用百度地图API的过程 1.安装 npm install vue - baidu - map -- save 2.全局注册 import Vue from 'vue' import BaiduMap from 'vue-baidu-map' Vue . use ( BaiduMap , { // ak 是在百度地图开发者平台申请的密钥 详见 http://lbsyun.baidu.com/apiconsole/key */ ak : 'YOUR_APP_KEY' }) 3.在vue文件中使用 template <template> <div> <baidu-map class = "bm-view" : center = "{lng: 116.404, lat: 39.915}" : zoom = "15" : scroll-wheel-zoom = "true" @ zoomend = "syncCenterAndZoom" : double-click-zoom = "true" > <!-- 缩放控件 --> <bm-scale anchor = "BMAP_ANCHOR_TOP_RIGHT" ></bm

unity 另类地景制作

匿名 (未验证) 提交于 2019-12-02 23:59:01
Shader "Unlit/360AlphaTest" { Properties{ _MainTex("Base (RGB)", 2D) = "white" {} _Cutoff("Alpha Cutoff", Range(0, 1)) = 0.5 } SubShader{ Tags {"Queue" = "AlphaTest" "IgnoreProjector" = "True" "RenderType" = "TransparentCutout"} Cull front LOD 100 Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" struct appdata_t { float4 vertex : POSITION; float2 texcoord : TEXCOORD0; }; struct v2f { float4 vertex : SV_POSITION; half2 texcoord : TEXCOORD0; }; sampler2D _MainTex; float4 _MainTex_ST; fixed _Cutoff; v2f vert(appdata_t v) { v2f o; o.vertex = UnityObjectToClipPos

Unity3D简单小游戏脚本(1):EatCoin

匿名 (未验证) 提交于 2019-12-02 23:59:01
今日闲来无事,敲些代码也无妨 1 //coin脚本,命名为Pickup 2 3 using System . Collections ; 4 using System . Colllections . Generic ; 5 using UnityEngine ; 6 7 public class Pickup : MonoBehaviour { 8 //初始化 9 void start (){ 10 } 11 //每帧刷新 12 void Updata (){ 13 transform . Rotate ( new Vector3 ( 30 , 30 , 30 )* Time . deltaTime ); 14 //随时间进行30°旋转 15 } 16 } //player脚本,命名为Player using System . Collections ; using System . Collections . Generic ; using UnityEngine ; using UnityEngine . UI ; public class Player : MonoBehaviour { Rigidbody rigid ; //定义刚体 float speed = 3 ; //设定速度 int count = 0 ; //设定金币数 public AudioClip

自定义ListView的Adapter

匿名 (未验证) 提交于 2019-12-02 23:59:01
一、自定义MyAdapter public class MyAdapter extends BaseAdapter { //Adapter的作用相当于是从数据到行布局的映射。这就需要传入需要显示的List数据 List < Map < String , Object >> list ; //反射器 LayoutInflater inflater ; //初始化反射器 public MyAdapter ( Context context ) { this . inflater = LayoutInflater . from ( context ); } //通过此方法初始化List public void setList ( List < Map < String , Object >> list ) { this . list = list ; } //如果返回默认的0,不管你传入什么List,全部都不显示 //返回list.size();就刚好显示list长度对应的条数。 @Override public int getCount () { return list . size (); } //因为使用的是List,这里就是设置了如何从List的下标如何得到List中的数据 @Override public Object getItem ( int position ) {

trackMotionScroll

匿名 (未验证) 提交于 2019-12-02 23:57:01
/** * Track a motion scroll * * @param deltaY Amount to offset mMotionView. This is the accumulated delta since the motion * began. Positive numbers mean the user's finger is moving down the screen. * @param incrementalDeltaY Change in deltaY from the previous event. * @return true if we're already at the beginning/end of the list and have nothing to do. */ boolean trackMotionScroll ( int deltaY , int incrementalDeltaY ) { final int childCount = getChildCount (); if ( childCount == 0 ) { return true ; } final int firstTop = getChildAt ( 0 ). getLeft (); final int lastBottom = getChildAt (

Unity3D的四种坐标系(转)

匿名 (未验证) 提交于 2019-12-02 23:57:01
【 Unity3D的四种坐标系 】 1、World Space(世界坐标):我们在场景中添加物体(如:Cube),他们都是以世界坐标显示在场景中的。transform.position可以获得该位置坐标。 2、Screen Space(屏幕坐标):以像素来定义的,以屏幕的左下角为(0,0)点, 右上角为(Screen.width,Screen.height) ,Z的位置是以相机的世界单位来衡量的。注:鼠标位置坐标属于屏幕坐标, Input.mousePosition 可以获得该位置坐标,手指触摸屏幕也为屏幕坐标, Input.GetTouch(0).position 可以获得单个手指触摸屏幕坐标。   Screen.height = Camera.pixelHeigth 3、ViewPort Space(视口坐标):视口坐标是标准的和相对于相机的。相机的左下角为(0,0)点,右上角为(1,1)点,Z的位置是以相机的世界单位来衡量的。 4、绘制GUI界面的坐标系:这个坐标系与屏幕坐标系相似,不同的是该坐标系以屏幕的左上角为(0,0)点, 右下角为(Screen.width,Screen.height) 。 【 四种坐标系的转换 】 1、世界坐标→屏幕坐标:camera.WorldToScreenPoint(transform.position);这样可以将世界坐标转换为屏幕坐标

我的matlab 的第一个gui工程

匿名 (未验证) 提交于 2019-12-02 23:56:01
注意,在设置position属性之前一定要先设置 units,不然会出错,无法显示radiobutton,同时,注意callback函数的特质与fcn的一些特殊规定,比如使用maxvalue,总体而言,matlab功能强大,确实值得一试,也算打了一天这个东西。 注意,如果不设置units,或者设置units为normalized,那么matlab的长1默认为150 像素,宽 60 function mygui s.hf = figure; set(s.hf,'toolbar','figure','menubar','none','numbertitle','off','name','example window','units','normalized','position',[0.3 0.4 0.6 0.5]); s.haxes = axes('parent',s.hf,'position',[0.1 0.1 0.5 0.8]); x=0:pi/50:2*pi; y = sin(x); axes(s.haxes); s.plot = plot(x,y,'b','linewidth',1.5); set(gca,'fontangle','italic','xcolor',[1 0 0]); grid on title('我的坐标轴'); xlabel('x_轴'); ylabel(

matlab脚本 gui设计基础

匿名 (未验证) 提交于 2019-12-02 23:56:01
h0 = figure('toolbar','none',... 'position',[200 150 450 250],... 'name','gui_mytry',... 'numbertitle','off'); x = 0:0.5:2*pi; y = sin(x); h = plot (x,y); grid on; hm = uicontrol(h0,'style','text',... 'string','绘图函数',... 'position',[380 180 50 20]); hm =uicontrol(h0,'style','popupmenu',... 'string',... 'sin(x)|cos(x)|sin(x)+cos(x)',... 'position',[380 150 50 20]); set(hm,'value',1) my_callback = [... 'v=get(hm,"value");,',... 'switch v,',... 'case 1,',... 'delete(h),',... 'y = sin(x);,',... 'h = plot(x,y);,',... 'grid on,'... 'case 1,',... 'delete(h),',... 'y = sin(x);,',... 'h = plot(x,y);,',

平滑曲线连接多个点

匿名 (未验证) 提交于 2019-12-02 23:52:01
贝塞尔曲线 参考资料: using System.Collections; using System.Collections.Generic; using UnityEngine; //https://en.wikipedia.org/wiki/Centripetal_Catmull%E2%80%93Rom_spline public class SmoothCurveHandler : MonoBehaviour { [SerializeField] LineRenderer lineRender; [SerializeField] List<Transform> posList; const int countBetween2Point = 20; Vector3[] curvePoints; void Start() { curvePoints = new Vector3[countBetween2Point * (posList.Count - 1) + 1]; lineRender.positionCount = curvePoints.Length; } void Update() { CalculateCurve(); lineRender.SetPositions(curvePoints); } //----------------------- Vector3