transform.Identity();
transform.Translate(pos);
for(int i = 0; i < numVerts; ++i) {
Vector3 newpos = transform.TransformVector(Vector3(verts.x, verts.y, verts.z));
verts.x = newpos.x;
verts.y = newpos.y;
verts.z = newpos.z;
}
Transform Vertex Coord: How?
Hello,
I want to transform my vertex coordinates into a specific position (e.g from (0,0,0) to (5, 0, 5) ).
I did like that (which doesn't give the needed results):
verts.x += pos.x;
verts.y += pos.y;
verts.z += pos.z;
i tried to use matrices. No luck:
this gives quite unexpected results. How can i do?
in my app, the pos value is set to Vec3(5,0,8). With matrices the 1st vertex (haven't watched others) translated from Vec3(1,2,-1) to Vec3(2,2,-1). But with just adding positions (the 1st one) it is translated to Vec3(6,2,7). after thinking a little bit about that i think the Vec3(6,2,7) is correct because its just one vertex of a cube. What do you think? Am i thinking correctly?
You cannot translate 3d vectors with matrices. You have to use 4d vectors with the 4:th component = 1 (homogeneous coordinates).
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement