Thread: DirectX : Problem related to applying transformations

  1. #1
    Registered User
    Join Date
    Dec 2011
    Posts
    12

    Angry DirectX : Problem related to applying transformations

    I started writing a basic window application and wanted to learn and make some primitives using DirectX.
    I created window, created device and did all the necessary things needed to be done before enjoying drawing.
    After declaring the vertices of a triangle, and then copying them to Vertex buffer, I rendered it. Finally, I got something on the screen .

    The problem started when I wanted to transform the triangle. I wrote the code, with intention of rotating it along Y-axis, but it didn't worked. This is what I wrote:
    D3DXMatrixIdentity(&mTestRotMat);
    D3DXMatrixRotationY( &mTestRotMat, D3DXToRadian(55));
    pd3dDevice->SetTransform(D3DTS_WORLD, &mTestRotMat);
    pd3dDevice->SetFVF( D3DFVF_XYZRHW | D3DFVF_DIFFUSE );
    pd3dDevice->SetStreamSource(0, m_v_buffer, 0,
    sizeof(vertex_info));
    pd3dDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 1);

    but this has no effect... :S
    Also, worst part is I tried changing the z-coordinates of the primitive, but the triangle remains at the same position...

    Am I missing anything ?

    NOTE : since, this is just the basic program, I have not implemented camera, nor I am manipulating any of View, Projection Matrix.

    Thanks,
    NJ
    Last edited by N Jagdish; 12-02-2011 at 04:30 AM.

  2. #2
    Registered User
    Join Date
    Dec 2011
    Posts
    12
    Hey guys, I got the answer my self
    I was unable to apply the transformation because I was using the Flexible Vertex Format as D3DFVF_XYZRHW, so I changed it to D3DFVF_XYZ and it works...

    Have fun

    Thanks,
    NJ

  3. #3
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    RHW is for drawing in screen space and turns off the transformation pipeline. I recommend using D3DFVF_XYZ with an orthographic projection matrix for doing 2D.

  4. #4
    Registered User
    Join Date
    Dec 2011
    Posts
    12
    Thanks VirtualAce. I will do that, in fact I already did that the things are working fine and as per expectation.


    Thanks,
    NJ

  5. #5
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Good. Glad to hear it worked out for you. The benefit now is that you can move your camera around and your objects will be affected since they are being fully transformed by the pipeline. Scaling, rotation, and the like are much simpler when you transform through the pipeline and you are also taking advantage of hardware acceleration since you are not transforming your vertices with D3DXVec3TransformCoord() or D3DXVec3TransformCoordArray(). For future reference if you are doing software transforms you should use ProcessVertices() instead of D3DXVec3TransformCoord() and D3DXVec3TransformCoordArray(). Check the SDK for details on why this is true.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OpenGL Transformations
    By Homunculus in forum Game Programming
    Replies: 4
    Last Post: 11-01-2011, 05:21 PM
  2. Replies: 1
    Last Post: 04-11-2007, 03:43 AM
  3. opengl model transformations
    By curlious in forum Game Programming
    Replies: 3
    Last Post: 09-06-2004, 02:30 PM
  4. DirectX transformations
    By confuted in forum Game Programming
    Replies: 9
    Last Post: 08-02-2003, 07:41 PM