dx9 tutorial help

Started by
20 comments, last by phil67rpg 10 years, 12 months ago

well I reread lesson 5

Advertisement
Ain't reading fun?
void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

yes I love reading




Posted 13 April 2013 - 04:03 PM


You'll want to create a static model of your pyramid. That means no variables in the pyramid declaration. Once that's done you use a transform to place the pyramid where you want to render it in the world.

well I have read the lesson 5 several times, I understand how to scale and rotate an object but don't understand of how to transform an object. what I want to do is draw several objects to the screen. I am able to draw a single object to the center of the screen. let me know if you need more explanation. I am trying to ask more intelligent questions.

To draw it more than once you just change the transform and then draw it again.


D3DXMatrixTranslation()

should be what you're looking for.

You have to reset the world matrix for every time you render the model. That means set the matrix to the identity, then do your scaling, rotation and translation -> every time. Once the matrix is set just do your draw call.

void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

well I have reread session 5 and 7 but I am still stuck I will do more research. thanks for all the help. should I post code?

should I post code?

yep!

ok here is the code I am working with

// this is the function used to render a single frame
void
 
 
render_frame(void)
{
d3ddev->Clear(0, 
 
NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
d3ddev->Clear(0, 
 
NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
d3ddev->BeginScene();
d3ddev->SetFVF(
 
CUSTOMFVF);
 
 
// set the view transform
 
 
D3DXMATRIX matView; // the view transform matrix
D3DXMatrixLookAtLH(&matView,
&
 
D3DXVECTOR3 (0.0f, 8.0f, 25.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 
 
 
// set the projection transform
 
 
D3DXMATRIX matProjection; // the projection transform matrix
D3DXMatrixPerspectiveFovLH(&matProjection,
 
 
D3DXToRadian(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
 
 
// set the world transform
 
 
static float index = 0.0f; index+=0.03f; // an ever-increasing float value
 
 
D3DXMATRIX matRotateY; // a matrix to store the rotation for each triangle
D3DXMatrixRotationY(&matRotateY, index); 
 
// the rotation matrix
d3ddev->SetTransform(
 
D3DTS_WORLD, &(matRotateY)); // set the world transform
 
 
// select the vertex buffer to display
d3ddev->SetStreamSource(0, v_buffer, 0, 
 
sizeof(CUSTOMVERTEX));
d3ddev->SetIndices(i_buffer);
 
 
// draw the Hypercraft
d3ddev->DrawIndexedPrimitive(
 
D3DPT_TRIANGLELIST, 0, 0, 10, 0, 6);
d3ddev->EndScene(); 
d3ddev->Present(
 
NULL, NULL, NULL, NULL);
}


D3DXMATRIX matRotateY, matTranslate, matWorld;

//generate the rotation
D3DXMatrixRotationY(&matRotateY, index); 

//generate the translation
D3DXMatrixTranslation(&matTranslate, x, y, z); 

//concatenate them into the world matrix - if you add scaling then it comes first (world = scale * rot * trans)
matWorld = matRotate * matTranslate;

d3ddev->SetTransform(D3DTS_WORLD, &matWorld);
void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

I am able to draw the triangular pyramid in the upper left corner of the screen. I just want to draw two pyramids to the screen. Thanks for all the help khatharr.

This topic is closed to new replies.

Advertisement