Transform error

I have created a simple mesh picking code and placed it under my mouseup event, here is the block of code

 

for(int i=0; i<50;i++)

{

//intersection information

IntersectInformation closest;

//the near vector

Vector3 near;

//the far vector

Vector3 far;

near = new Vector3(e.X, e.Y, 0); //the mouse coordinates

far = new Vector3(e.X, e.Y, 1); //the mouse coordinates

near.Unproject(sampleFramework.Device.Viewport,sampleFramework.Device.Transform.Projection, sampleFramework.Device.Transform.View, Matrix.Translation(MapXIdea, MapYIdea, MapZIdea));

far.Unproject(sampleFramework.Device.Viewport, sampleFramework.Device.Transform.Projection, sampleFramework.Device.Transform.View, Matrix.Translation(MapXIdea, MapYIdea, MapZIdea));

far.Subtract(near);

if(mesh2.Intersect(near, far, out closest))

{

}

}

when near.Unproject() runs I get this error

Error in the application.
-2005530516 (D3DERR_INVALIDCALL)
   at Microsoft.DirectX.Direct3D.Device.GetTransform(TransformType state, Int32*
 result)
   at Microsoft.DirectX.Direct3D.Device.GetTransform(TransformType state)
   at Microsoft.DirectX.Direct3D.Transforms.get_Projection()
   at Project1.Start.WindowForm_MouseUp(Object sender, MouseEventArgs e)

any ideas

 



Answer this question

Transform error

  • Josh D

    You probably have a pure device - you cannot read back device state such as transforms and renderstates from a pure device. So either cache a copy of the transforms or change the device to be non pure.

  • Transform error