World translation differences between DrawSubset(...) and DrawPrimitive(...)?

Using C++ and Direct X 9 i have now boxes, sphere and cylinders ect using the functions provided in the Shape Drawing Functions list e.g.

HRESULT D3DXCreateBox(      

    LPDIRECT3DDEVICE9 pDevice,     FLOAT Width,     FLOAT Height,     FLOAT Depth,     LPD3DXMESH *ppMesh,     LPD3DXBUFFER *ppAdjacency );
Now using matrix translations of the world you can position
origin, in effect, to be wherever you want it to be.
So this is created and shown at the current world origin.
So now i want to draw a line
and primitives using DrawPrimitives and vertex buffers.
Expecting it to draw from origin. e.i. 0,0,0 would be where "origin"
is postioned currently. This doesn't seem to be the case at all
it draws 0,0,0 in the top left hand corner of the screen. Not at the new
"origin" created using the transformations i've already applied.
So my question is how do i get the orgin of the primitives to be draw to
line up and match with the world translation that is positioning the cubiod.


Answer this question

World translation differences between DrawSubset(...) and DrawPrimitive(...)?

  • Atilla Koklu

    The only time you should be getting the origin as the top-left of the screen is if you're passing in "transformed" geometry. That is, you're trying to do 2D rather than 3D rendering.

    ID3DXLine is a 2D utility, thus its origin will be top-left, as will any vertex data created with D3DFVF_XYZRHW in the FVF (or using the POSITIONT semantic in shaders).

    For any other custom geometry, then it's only based around the origin if you create it that way - it's quite possible to break this and, using your assumption, get some odd results.

    hth
    Jack


  • Tom Nguyen-Marsh MSFT

    Ah i didn't realise vertices created using D3DFVF_XYZRHW would be 2D only. I've got it working correctly now. Many thanks.
  • World translation differences between DrawSubset(...) and DrawPrimitive(...)?