Move a Mesh

Newbie Question here,

How does one move a mesh around in a 3d space The only thing I can seem to do is move the camera around it. I have my mesh loaded up and everything, I just want to know how to change its x,y, and z coordinates. Thank you!



Answer this question

Move a Mesh

  • DarylKanary

    class World
    {
    private Device _device;
    private _transform1, _transform2;

    public World( Device device )
    {
    _device = device;

    _transform1 = Matrix.Translation( x1, y1, z1 );
    _transform2 = Matrix.Translation( x2, y2, z2 );
    }

    public void Daw()
    {
    _device.Transform.World = _trasform1;
    (draw mesh1)

    _device.Transform.World = _trasform2;
    (draw mesh2)
    }
    }

    just set the Device.Transform.World property to the matrix of each mesh before you draw it

  • Gillett

    To display in DX you need to set 3 matrix PROJECTION, VIEW and WORLD

    http://msdn.microsoft.com/library/default.asp url=/library/en-us/directx9_c/Projection_Transform.asp

    http://msdn.microsoft.com/library/default.asp url=/library/en-us/directx9_c/View_Transform.asp

    http://msdn.microsoft.com/library/default.asp url=/library/en-us/directx9_c/World_Transform.asp

    You set the projection each time the window change proportion
    but only once by frame

    You set the View each time you change you point of view of where you look at
    Only once by frame

    You use LookAt Function to set it easily

    For the World matrix you define one each time you need to displace something
    in the world

    So you set the fist 2 matrix
    And then set one world matrix for each of your object in the scene

    Set World Matrix
    Draw Mesh 1

    Set World Matrix at different position and rotation
    Draw Mesh 2

    Think about the VIEW matrix as ONE oriented camera in the scene

    And think of the WORLD matrix as the placement matrix for any object in the scene

    So you set many time the WORLD matrix to move stuff around









  • Puru

    Also, how would I change the positions of two different meshes
  • Salman and Tahir

    Okay, so something like this

    mydevice.Transform.World = Matrix.Translation(myx,myy,myz);

    Then I could just get keyinput to either add to myx, myy, or myz

    Thanks!


  • Move a Mesh