Results 1 to 8 of 8
  1. #1
    schim's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    My chair
    Posts
    367
    Reputation
    10
    Thanks
    114
    My Mood
    Twisted

    [QUESTION] D3D problems :D

    Ok, so I'm still planning on making game hacks sometime in the future and I'm following a Direct3D tutorial here but now I'm stuck.
    I have already done everything that the guy on the tutorial page has done and the programs compiles just right no problems at all.
    But, now I want to go a bit further. I want to draw 2 Triangles to the screen which are rotating. This isn't the problem either the problem is that I can see my 2nd smaller triangle through the other triangle :O

    I think I know why, because I use a rather noob way of drawing these 2 triangles:

    Code:
    void render_frame(void)
    {											//D3DCOLOR_XRGB(r, g, b)
        // clear the window to a deep blue		D3DCOLOR_ARGB(136, r, g, b);
        d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
    
        d3ddev->BeginScene();    // begins the 3D scene
    
                // select which vertex format we are using
            d3ddev->SetFVF(CUSTOMFVF);
    
             // SET UP THE PIPELINE
    
        D3DXMATRIX matRotateY;    // a matrix to store the rotation information
    
        static float index = 0.0f; index+=0.05f;    // an ever-increasing float value
    
        // build a matrix to rotate the model based on the increasing float value
        D3DXMatrixRotationY(&matRotateY, index);
    
        // tell Direct3D about our matrix
        d3ddev->SetTransform(D3DTS_WORLD, &matRotateY);
    
        D3DXMATRIX matView;    // the view transform matrix
    
        D3DXMatrixLookAtLH(&matView,
                           &D3DXVECTOR3 (0.0f, 0.0f, 10.0f),    // the camera position
                           &D3DXVECTOR3 (0.0f, 0.0f, 0.0f),    // the look-at position
                           &D3DXVECTOR3 (0.0f, 1.0f, 0.0f));    // the up direction
    
        d3ddev->SetTransform(D3DTS_VIEW, &matView);    // set the view transform to matView
    
        D3DXMATRIX matProjection;     // the projection transform matrix
    
        D3DXMatrixPerspectiveFovLH(&matProjection,
                                   D3***oRadian(45),    // the horizontal field of view
                                   (FLOAT)SCREEN_WIDTH / (FLOAT)SCREEN_HEIGHT, // aspect ratio
                                   1.0f,    // the near view-plane
                                   100.0f);    // the far view-plane
    
        d3ddev->SetTransform(D3DTS_PROJECTION, &matProjection);    // set the projection
    
       
           d3ddev->SetStreamSource(0, v_buffer, 0, sizeof(CUSTOMVERTEX) ); //Drawing my 1st triangle here
    
    		
            // copy the vertex buffer to the back buffer  
            d3ddev->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1);                     //Drawing my 1st triangle here
    
    
    				
        
    d3ddev->SetStreamSource(0, v_buffer1, 0, sizeof(CUSTOMVERTEX1));     //Drawing my 2nd triangle here
     d3ddev->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1);                           //Drawing my 2nd triangle here
    
        d3ddev->EndScene();    // ends the 3D scene
    
        d3ddev->Present(NULL, NULL, NULL, NULL);   // displays the created frame on the screen
    }
    Yes, I did C&P this right out of the tutorial, that's how I learn, I read the tutorial copy the code and start playing around with the functions until I think I got it.
    So can anyone help me?

    -SCHiM

  2. #2
    why06's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    IBM
    Posts
    4,304
    Reputation
    170
    Thanks
    2,203
    My Mood
    Flirty
    screenshot plz.

    "Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."
    - Dwight D. Eisenhower

  3. #3
    schim's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    My chair
    Posts
    367
    Reputation
    10
    Thanks
    114
    My Mood
    Twisted
    Quote Originally Posted by why06 View Post
    screenshot plz.
    Oops it seems like I'm a real idiot :O
    I was fooled by my own program. The triangle doesn't disappear behind the 2nd triangle because it never goes there It's just hanging in front of the bigger triangle

    But that raises another question, how can I make the 2nd triangle disappear behind the 1st??

    Here's the video BTW: (I thought making a video would be clearer since my triangles are in a constant motion)
    [YOUTUBE]Byc_iCQ1khA[/YOUTUBE]

    The I thought about using:
    Code:
    d3ddev->SetRenderState(D3DRS_CULLMODE,  D3DCULL_CCW);
    But then my 1st triangle would be cut in half too
    Last edited by schim; 06-11-2010 at 11:55 PM.

  4. #4
    schim's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    My chair
    Posts
    367
    Reputation
    10
    Thanks
    114
    My Mood
    Twisted
    //Solved

    My question is solved in the next page of the tutorial

  5. #5
    mwb1234's Avatar
    Join Date
    May 2009
    Gender
    male
    Posts
    460
    Reputation
    7
    Thanks
    65
    Quote Originally Posted by schim View Post
    //Solved

    My question is solved in the next page of the tutorial
    Next time try to EDIT if you can. We don't like double posting here at MPGH. I was looking for a solution for but not I can stop. What function did you end up calling?

  6. #6
    schim's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    My chair
    Posts
    367
    Reputation
    10
    Thanks
    114
    My Mood
    Twisted
    Quote Originally Posted by mwb1234 View Post
    Next time try to EDIT if you can. We don't like double posting here at MPGH. I was looking for a solution for but not I can stop. What function did you end up calling?
    I ended up using a zbuffer wich is a buffer that keeps track of the distance between the camera and the screen
    Here is an in depth explaination

  7. #7
    mwb1234's Avatar
    Join Date
    May 2009
    Gender
    male
    Posts
    460
    Reputation
    7
    Thanks
    65
    Quote Originally Posted by schim View Post
    I ended up using a zbuffer wich is a buffer that keeps track of the distance between the camera and the screen
    Here is an in depth explaination
    I was just wondering if you did it right. I know my D3D... Good work, and keep working hard. Programming takes a LOT of dedication to learn fully in depth. And D3D is a great place to learn to do chams

  8. #8
    why06's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    IBM
    Posts
    4,304
    Reputation
    170
    Thanks
    2,203
    My Mood
    Flirty
    Quote Originally Posted by schim View Post
    I ended up using a zbuffer wich is a buffer that keeps track of the distance between the camera and the screen
    Here is an in depth explaination
    yep, i was wondering if the triangles were infront of each other, or side by side or something, but since u figured it out goodjob.

    "Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."
    - Dwight D. Eisenhower

Similar Threads

  1. [Request Help] D3D problem
    By icebox2010 in forum WarRock Tutorials
    Replies: 4
    Last Post: 11-07-2010, 12:37 PM
  2. d3d problem
    By nubs in forum Combat Arms Help
    Replies: 3
    Last Post: 01-25-2010, 06:15 AM
  3. <Question> got a bit of a problem
    By WTFPinkHair in forum Combat Arms Mod Discussion
    Replies: 7
    Last Post: 01-08-2010, 12:22 PM
  4. Problem D3D code
    By ciauz51 in forum C++/C Programming
    Replies: 3
    Last Post: 08-25-2009, 03:34 PM
  5. Question: Simple Chams D/C problem.
    By deathninjak0 in forum Combat Arms Hacks & Cheats
    Replies: 4
    Last Post: 03-06-2009, 05:02 PM