Results 1 to 5 of 5

Thread: Won't render the triangle if....

  1. #1

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827

    Won't render the triangle if....

    Currently, I have using the following array of vertices to draw a triangle:
    PHP Code:

            CUSTOMVERTEX g_vertices
    [] = 
            {
                { -
    1.0f, -1.0f0.0fD3DCOLOR_XRGB(255,0,255), }, // x, y, z, color
                
    1.0f, -1.0f0.0f,  D3DCOLOR_XRGB(0,255,0), },
                {  
    0.0f1.0f0.0fD3DCOLOR_XRGB(0,0,255),}, 
    and I am also transforming the world matrix every time I render (in a loop) so the above triangle is rotated on X axis using the following code:
    PHP Code:
        //set the world matrics (rotate the object on Y)
        
    D3DXMatrixRotationX(&mattimeGetTime()/250.0f);
            if(
    FAILED(lpD3DDev->SetTransform(D3DTS_WORLD, &mat)))
            {
                
    ShowError("Unable to set the world matrics");
                return 
    false;
            } 
    Above code works fine but when I don't use the world transformation (I don't rotate any object means I don't use 2nd piece of code^^), the triangle won't show up. Why is it doing that?
    Baaaaaaaaah

  2. #2

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    Ahhh, thanks. Works now.
    Another thing, to draw the triangle, I provided its vertices with the coordinates in very small and sometime negative numbers (eg 0.0f, 1.0f, -1.0f). How would I change that unit to pixels (eg 343, 343, 343) and how would I make Direct3D recognize that I am providing the points in pixels not the form I was providing in before?
    Baaaaaaaaah

  3. #3
    Zaei
    Guest
    Use the FVF:
    Code:
    D3DFVF_XYZ | D3DFVF_RHW | D3DFVF_DIFFUSE
    I believe that is correct. Your vertex structure should look like this:
    Code:
    struct vertex
    {
      float x;
      float y;
      float z;
      float rhw;
      unsigned long color;
    };
    Set rhw to 1.0f. x and y are the screen pixel coordinates, and z is the raw depth in the depth buffer (i usually set this to something really small).

    Z.

  4. #4

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    Thanks, now I also understand what rhw thingy is used for.
    Baaaaaaaaah

  5. #5
    Zaei
    Guest
    Sure thing.

    Z.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width