it is something I don't understand on transforming (meshes). Please take a look at my code (which is in Render() function) first:
foreach (GeometricObject obj in this.objects)
{
if (obj != this.activeObject)
{
obj.Mesh = MeshUtils.ChangeMeshColor(obj.Mesh, Color.Yellow, device);
}
else
{
obj.Mesh = MeshUtils.ChangeMeshColor(obj.Mesh, Color.Green, device);
obj.GeometryMatrix.Translate(this.move);
}
device.Transform.World = obj.GeometryMatrix;
obj.Mesh.DrawSubset(0);
}
Explanation: I have got some yellow gometriObjects (meshes) and one green activeObject (I can switch between them by keyboard 1-4). 'move' is a vector that I change after every arrow is selected on keybo开发者_C百科ard (so I can move the active objects).
BUT it is not working as I wanted to. ...if I change the position of one of my objects...then after switching to the other (changing activeObject) I got the other view on the screen (after all switches ... all objects are in the same place of the screen;/). Why is that it isn't the same view for all the time? I think...it should, because I have got the same view setted:
device.Transform.View = Matrix.LookAtLH(new Vector3(0.0f, 2.0f, -25.0f), // Camera position
new Vector3(0.0f, 0.0f, 0.0f), // Look-at point
new Vector3(0.0f, 1.0f, 0.0f)); // Up vector
So what's my problem? Any ideas:)? Aha...the problem isn't connected with that changingMeshColor function...i checked.
Ech....it started to work after changing:
obj.GeometryMatrix.Translate(this.move);
to:
obj.GeometryMatrix *= Matrix.Translation(this.move);
...but why is that? I really don't know... Translate() should change my matrix, not set as a translation (as it did)
精彩评论