Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Vector getPoint(Vector p0,Vector p1,Vector p2,Vector p3,float x)
- {
- Vector ans = new Vector ();
- Vector p0t = new Vector (p0);
- Vector p1t = new Vector (p1);
- Vector p2t = new Vector (p2);
- Vector p3t = new Vector (p3);
- float c3;
- float c2;
- float c1;
- float c0;
- c3 = (2 * x * x * x) - (3 * x * x) + 1;
- c2 = (x * x * x) - (2 * x * x) + x;
- c1 = (-2 * x * x * x) + (3 * x * x);
- c0 = (x * x * x) - (x * x);
- p0t.multiply (c3);
- p1t.multiply (c1);
- p2t.multiply (c2);
- p3t.multiply (c0);
- ans.add (p0t);
- ans.add (p1t);
- ans.add (p2t);
- ans.add (p3t);
- return ans;
- }
- public void renderCurve()
- {
- Vector p0,p1,p2,p3,p;
- for (int i = 0; i < points.Length; i = i + 4)
- {
- p0 = new Vector (points[i].x,points[i].y,points[i].z);
- p1 = new Vector (points[i + 1].x,points[i + 1].y,points[i + 1].z);
- p2 = new Vector (points[i + 2].x,points[i + 2].y,points[i + 2].z);
- p3 = new Vector (points[i + 3].x,points[i + 3].y,points[i + 3].z);
- for (float t = 0; t <= 1; t = (t + Time.deltaTime * 10))
- {
- p = hermite.getPoint (p0,p1,p2,p3,t);
- GameObject pobj = Instantiate (pointObject, new Vector3(p.x,p.y,0.0f), Quaternion.identity) as GameObject;
- }
- }
- }
Add Comment
Please, Sign In to add comment