Move 3D Object on Screen

Try to use mouse to move the object on screen. Such as the "PAN" action for 3d application. I converted screen coordinate to world coordinate. But result is wrong. Wish to get help. Thanks.

[216 byte] By [FlyingSun] at [2007-12-22]
# 1

"It doesn't work - please help" is saldy not enough information to go on.

There are lots of samples for 'picking' out there in native, managed, DirectX and OpenGL - have you tried to work through those?

TheZMan at 2007-8-30 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: General...
# 2
I appreciate if you could give detailed info. Examples will be great. Thanks.
FlyingSun at 2007-8-30 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: General...
# 3

Maybe if you let us know

a) what language you are using

b) what you have tried so far and what doesn't work

c) what samples you have searched for yourself and why those don't work for you. Searching google, these forums and those on gamedev.net and you will find this questions has been answered many, many times. e.g. here is one using c# http://www.mdxinfo.com/tutorials/picking.php

TheZMan at 2007-8-30 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: General...
# 4

Thanks. It's great help. I am using C# and similar method you mentioned. Here is my code:

Movement is the class which has the properties of mouse drag start position(XStart, YStart) and end position (X, Y)

Thanks a lot.

public void Move(Movement movement)

{

Vector3 startPosition = new Vector3(movement.XStart, movement.YStart, 0.0F);

Vector3 endPosition = new Vector3(movement.X, movement.Y, 0.0F);

startPosition = Vector3.Unproject(

startPosition,

device.Viewport,

device.Transform.Projection,

device.Transform.View,

device.Transform.World);

endPosition = Vector3.Unproject(

endPosition,

device.Viewport,

device.Transform.Projection,

device.Transform.View,

device.Transform.World);

Vector3 moveVector = Vector3.Subtract(endPosition, startPosition);

Matrix translationMatrix = Matrix.Translation(moveVector);

device.Transform.World *= translationMatrix;

}

FlyingSun at 2007-8-30 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: General...
# 5

Could anyone help? I still haven't got solution yet. Thanks.

FlyingSun at 2007-8-30 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: General...