本文整理汇总了C#中CRSpline类的典型用法代码示例。如果您正苦于以下问题:C# CRSpline类的具体用法?C# CRSpline怎么用?C# CRSpline使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CRSpline类属于命名空间,在下文中一共展示了CRSpline类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Awake
void Awake()
{
// Allocate the various arrays here to avoid
// allocations during the game loop.
bandData = new float[Spectrum.N_BANDS];
bandPoints = new Vector3[Spectrum.N_BANDS + 2];
splinePoints = new Vector3[nPoints];
colliderPoints = new Vector2[nPoints + 2];
spline = new CRSpline(bandPoints);
}
开发者ID:reluctantmedia,项目名称:BeatBurst,代码行数:10,代码来源:SpectrumVisualiser.cs
示例2: Start
// Use this for initialization
void Start ()
{
Vector3[] drawPath = iTweenPath.GetPath("test path");
spline = new CRSpline(drawPath);
t = 0.0f;
/*
iTween.MoveTo(gameObject,
iTween.Hash(
"path", iTweenPath.GetPath("test path"),
"looptype", "loop",
"time", 10,
"movetopath", false
));
*/
}
开发者ID:ntchung,项目名称:cosmonova,代码行数:19,代码来源:test.cs
示例3: GenerateMoveToPathTargets
void GenerateMoveToPathTargets()
{
Vector3[] suppliedPath;
//create and store path points:
if(tweenArguments["path"].GetType() == typeof(Vector3[])){
Vector3[] temp = (Vector3[])tweenArguments["path"];
//if only one point is supplied fall back to MoveTo's traditional use since we can't have a curve with one value:
if(temp.Length==1){
Debug.LogError("iTween Error: Attempting a path movement with MoveTo requires an array of more than 1 entry!");
Dispose();
}
suppliedPath=new Vector3[temp.Length];
Array.Copy(temp,suppliedPath, temp.Length);
}else{
Transform[] temp = (Transform[])tweenArguments["path"];
//if only one point is supplied fall back to MoveTo's traditional use since we can't have a curve with one value:
if(temp.Length==1){
Debug.LogError("iTween Error: Attempting a path movement with MoveTo requires an array of more than 1 entry!");
Dispose();
}
suppliedPath = new Vector3[temp.Length];
for (int i = 0; i < temp.Length; i++) {
suppliedPath[i]=temp[i].position;
}
}
//do we need to plot a path to get to the beginning of the supplied path?
bool plotStart;
int offset;
if(transform.position != suppliedPath[0]){
if(!tweenArguments.Contains("movetopath") || (bool)tweenArguments["movetopath"]==true){
plotStart=true;
offset=3;
}else{
plotStart=false;
offset=2;
}
}else{
plotStart=false;
offset=2;
}
//build calculated path:
vector3s = new Vector3[suppliedPath.Length+offset];
if(plotStart){
vector3s[1]=transform.position;
offset=2;
}else{
offset=1;
}
//populate calculate path;
Array.Copy(suppliedPath,0,vector3s,offset,suppliedPath.Length);
//populate start and end control points:
//vector3s[0] = vector3s[1] - vector3s[2];
vector3s[0] = vector3s[1] + (vector3s[1] - vector3s[2]);
vector3s[vector3s.Length-1] = vector3s[vector3s.Length-2] + (vector3s[vector3s.Length-2] - vector3s[vector3s.Length-3]);
//is this a closed, continuous loop? yes? well then so let's make a continuous Catmull-Rom spline!
if(vector3s[1] == vector3s[vector3s.Length-2]){
Vector3[] tmpLoopSpline = new Vector3[vector3s.Length];
Array.Copy(vector3s,tmpLoopSpline,vector3s.Length);
tmpLoopSpline[0]=tmpLoopSpline[tmpLoopSpline.Length-3];
tmpLoopSpline[tmpLoopSpline.Length-1]=tmpLoopSpline[2];
vector3s=new Vector3[tmpLoopSpline.Length];
Array.Copy(tmpLoopSpline,vector3s,tmpLoopSpline.Length);
}
//create Catmull-Rom path:
path = new CRSpline(vector3s);
//need for speed?
if(tweenArguments.Contains("speed")){
float distance = PathLength(vector3s);
time = distance/(float)tweenArguments["speed"];
}
}
开发者ID:hyf042,项目名称:BakeryGirl-chess,代码行数:79,代码来源:iTween.cs
示例4: JsonLoad
//Json文件加载
private void JsonLoad(string path_name, CRSpline crSpline, ref bool is_right, Transform parent_trans)
{
string filePath = MotionPara.taskRootPath + MotionPara.taskName + "/PathControl.json";
if (File.Exists(filePath))
{
JsonOperator jsonOp = new JsonOperator();
DataTable jsonTable = jsonOp.JsonReader(filePath, path_name);
if (jsonTable == null)
{
Debug.LogError(path_name + ", 该路径名称不存在!");
return;
}
GameObject loadEmpty = new GameObject();
loadEmpty.name = "JsonLoad_empty";
loadEmpty.transform.parent = parent_trans;
for (int i = 0; i < jsonTable.Rows.Count; i++)
{
loadEmpty.transform.localPosition = ConvertToVector3((string)jsonTable.Rows[i][0].ToString());
loadEmpty.transform.localEulerAngles = ConvertToVector3((string)jsonTable.Rows[i][1].ToString());
crSpline.controlPoints.Add(loadEmpty.transform.position);
crSpline.rotationList.Add(loadEmpty.transform.eulerAngles);
crSpline.cameraViewList.Add(float.Parse((string)jsonTable.Rows[i][2].ToString()));
}
GameObject.DestroyImmediate(loadEmpty);
}
else
{
Debug.LogError(filePath + ", 该文件不存在!");
}
}
开发者ID:xiaopangoo,项目名称:MotionPlatform,代码行数:31,代码来源:ExcelInfoClass.cs
示例5: DistributeNodes
public void DistributeNodes()
{
int numNodes = path.Count;
//if (numNodes<5) return;
Vector3[] newpositions = new Vector3[numNodes];
Vector3[] positions = new Vector3[numNodes];
for(int i=0; i<positions.Length; i++)
{
if( path[i] != null )
positions[i] = path[i].position;
}
CRSpline posSpline = new CRSpline( positions );
for (int a=1; a<positions.Length-1; a++)
{
float p = (1.0f / ((float)numNodes-3.0f)) * (a-1);
//Debug.Log(p+","+getT( splineLenght*p ));
newpositions[a] = posSpline.Interp(getT( splineLenght*p ));
}
for (int a=1; a<positions.Length-1; a++)
path[a].position = newpositions[a];
}
开发者ID:Gounemond,项目名称:GGJ2016,代码行数:28,代码来源:PathScript.cs
示例6: generateMesh
void generateMesh()
{
if(meshPrefab==null)
return;
List<Vector3> vertices=new List<Vector3>();
List<int>[] triangles=new List<int>[3];
triangles[0]=new List<int>();
triangles[1]=new List<int>();
triangles[2]=new List<int>();
List<Vector2> uv=new List<Vector2>();
List<Vector3> normals=new List<Vector3>();
List<Vector4> tangents=new List<Vector4>();
CRSpline posSpline = new CRSpline( path.getPositions() );
//CRSpline rotSpline = new CRSpline( path.getRotations() );
Mesh[] mesh=new Mesh[3];
mesh[0]=meshPrefab.FindChild("start").GetComponent<MeshFilter>().sharedMesh;
mesh[1]=meshPrefab.FindChild("middle").GetComponent<MeshFilter>().sharedMesh;
mesh[2]=meshPrefab.FindChild("end").GetComponent<MeshFilter>().sharedMesh;
Vector3[][] meshVertices=new Vector3[3][];
int[][] meshTriangles=new int[3][];
Vector2[][] meshUv=new Vector2[3][];
Vector3[][] meshNormals=new Vector3[3][];
Vector4[][] meshTangents=new Vector4[3][];
float[] max=new float[3];
for(int i=0;i<3;i++)
{
meshVertices[i]=mesh[i].vertices;
meshTriangles[i]=mesh[i].GetTriangles(0);
meshUv[i]=mesh[i].uv;
meshNormals[i]=mesh[i].normals;
meshTangents[i]=mesh[i].tangents;
for(int vi=0;vi<meshTriangles[i].Length;vi++)
{
if(meshVertices[i][meshTriangles[i][vi]].x>max[i])
max[i]=meshVertices[i][meshTriangles[i][vi]].x;
}
}
float cursor=0;
int vertI=0;
int meshI=0;
if(path.round)
meshI=1;
bool last=false;
//float scale=1;
while(true)
{
if(meshI==2)
break;
if(getT(cursor+max[meshI])<1.0f || last)
{
if(last)
{
//scale=1.0f/(getT(cursor+max[meshI])-getT(cursor))*(1.0f-getT(cursor));
}
if(getT(cursor+max[meshI]+max[2])>1.0f && !path.round)
meshI=2;
for(int i=0;i<meshTriangles[meshI].Length;i++)
{
triangles[meshI].Add(vertI+meshTriangles[meshI][i]);
}
vertI+=mesh[meshI].vertexCount;
for(int i=0;i<meshVertices[meshI].Length;i++)
{
float vertexCursor=cursor+Mathf.Max(meshVertices[meshI][i].x,0);
float t=getT(vertexCursor);
Vector3 vPos=posSpline.Interp(t);
Vector3 look=posSpline.Velocity(t).normalized;
Quaternion r=Quaternion.LookRotation(look);
r=Quaternion.Euler(0,-90,0)*Quaternion.Euler(r.eulerAngles.z,(r.eulerAngles.y),-r.eulerAngles.x);
Vector3 localVert=meshVertices[meshI][i];
localVert.x=0;
Vector3 vert=(r*localVert)+(vPos-transform.position);
//vert.x-=middleVertices[i].x;
//Debug.Log(t);
vertices.Add(vert);
uv.Add(meshUv[meshI][i]);
normals.Add(r*meshNormals[meshI][i]);
tangents.Add(r*meshTangents[meshI][i]);
}
//Debug.Log(max);
cursor+=max[meshI];
if(meshI==0)
meshI=1;
//.........这里部分代码省略.........
开发者ID:Gounemond,项目名称:GGJ2016,代码行数:101,代码来源:PathMesh.cs
示例7: easePath
protected void easePath( )
{
positionSpline = new CRSpline( path.getPositions() );
rotationSpline = new CRSpline( path.getRotations() );
float startI=(1.0f/(positionSpline.pts.Length-3))*(pathStartNode-1);
float endI=(1.0f/(positionSpline.pts.Length-3))*(pathEndNode-1);
float i=startI+ ((endI-startI)*normalizedTime);
Vector3 newPos = positionSpline.Interp( i );
if (transform==null)
{
Debug.Log("EasePath error: "+easingGroup + " " + animationCurveName);
return;
}
if(space==Space.World)
transform.position = newPos;
else
transform.localPosition = newPos;
if( lookAtTransform!= null )
{
transform.LookAt( lookAtTransform, vectorUp );
}
else if( pathAlignWithSpeed )
{
Vector3 velVector = positionSpline.Velocity( i);
if(space==Space.World)
transform.rotation = Quaternion.LookRotation( velVector );
else
transform.localRotation = Quaternion.LookRotation( velVector );
}
else
{
Vector3 newRot = rotationSpline.Interp( i );
if(space==Space.World)
transform.rotation = Quaternion.Euler( newRot );
else
transform.localRotation = Quaternion.Euler( newRot );
}
}
开发者ID:Gounemond,项目名称:GGJ2016,代码行数:43,代码来源:Easing.cs
注:本文中的CRSpline类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论