Skip to main content
gamedev.net
🔒 Locked 🎮 Unity

DX panel

Started by Ajvan 0 replies 700+ views
Original Post
Ajvan
Ajvan
Im working in VS2005 C#, make DX panel and try to load some .x files exported from 3ds max. It works fine until some point. When I try to load several .x files one after another, it seems like world coordinate system changes its origins. When I click on the panel, first .x file (first mesh) draws exactly where I click. But, when I click to draw second mesh somewere on DX panel it draws some points away from my click. Third also, and so on. Can anyone tell me whats going on, please? heres the code: camera setup: device.Transform.World = Matrix.Identity; device.Transform.Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4, panel1.Width / panel1.Height, 1.0f, 1000.0f); device.Transform.View = Matrix.LookAtLH(new Vector3(0, 0, 600.0f), new Vector3(0, 0, 0), new Vector3(0, 1, 0)); and then calculate screen to world coordinates: Vector3 tempV3 = v3CurrMeshPos; //value of the v3CurrMeshPos vector is (0,0,0) tempV3.Project(device.Viewport, device.Transform.Projection, device.Transform.View, device.Transform.World); tempV3.X = x; tempV3.Y = y; tempV3.Unproject(device.Viewport, device.Transform.Projection, device.Transform.View, device.Transform.World); then, draw the mesh on the tempV3.X and tempV3.Y coordinates. any suggestion will be helpful

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.