HRESULT CMyD3DApplication::Render()
{
// Set up viewing postion from ArcBall
SDrawElement *pdeCur;
D3DXMATRIXA16 mat;
pdeCur = m_pdeHead;
// Clear the viewport
m_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,0), 1.0f, 0 );
if (m_pdeHead == NULL)
{
return S_OK;
}
// Begin the scene
if( SUCCEEDED( m_pd3dDevice->BeginScene() ) )
{
UINT cTriangles = 0;
HRESULT hr;
SDrawElement *pdeCur;
D3DXMATRIXA16 mCur;
D3DXVECTOR3 vTemp;
D3DXMATRIX matWorld;
D3DXMatrixRotationY( &matWorld, 0.0f );
m_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
D3DXMATRIX matView;
D3DXMatrixLookAtLH( &matView, &D3DXVECTOR3( cv2CameraEye.x, cv2CameraEye.y, cv2CameraEye.z ),
&D3DXVECTOR3( cv2CameraTarget.x, cv2CameraTarget.y, cv2CameraTarget.z ),
&D3DXVECTOR3( cv2CameraUp.x, cv2CameraUp.y, cv2CameraUp.z ) );
m_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
D3DXMATRIX matProj;
D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, 1.0f, 1.0f, 2000.0f );
m_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );//D3DTA_TEXTURE ); // or D3DTA_SPECULAR
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP ); //only used on textures
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP ); //only used on textures
m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, FALSE );
m_pd3dDevice->SetRenderState( D3DRS_NORMALIZENORMALS, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_ZWRITEENABLE, FALSE );
m_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CW );
// NEW CODE STARTS HERE
CUSTOMVERTEX* h_Vertices;
if( FAILED( m_pVB->Lock( 0, 0, (BYTE**)&h_Vertices, 0 ) ) )
return E_FAIL;
h_Vertices[0].x = 0;
h_Vertices[0].y = 0;
h_Vertices[0].z = 0;
h_Vertices[0].color = 0xffffff;
h_Vertices[0].tu = 0.0;
h_Vertices[0].tv = 1.0;
h_Vertices[1].x = 0;
h_Vertices[1].y = 10;
h_Vertices[1].z = 0;
h_Vertices[1].color = 0xffffff;
h_Vertices[1].tu = 0.0;
h_Vertices[1].tv = 0.0;
h_Vertices[2].x = 0;
h_Vertices[2].y = 0;
h_Vertices[2].z = 10;
h_Vertices[2].color = 0xffffff;
h_Vertices[2].tu = 1.0;
h_Vertices[2].tv = 1.0;
m_pVB->Unlock();
//m_pd3dDevice->SetTexture( 0, tGrid[10] );
m_pd3dDevice->SetStreamSource( 0, m_pVB, sizeof(CUSTOMVERTEX) );
m_pd3dDevice->SetVertexShader( D3DFVF_CUSTOMVERTEX );
m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 1 );
// NEW CODE ENDS HERE
m_pd3dDevice->SetRenderState( D3DRS_NORMALIZENORMALS, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CW );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );//D3DTA_TEXTURE ); // or D3DTA_SPECULAR
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_CURRENT );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_POINT );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_POINT );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP ); //only used on textures
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP ); //only used on textures
if( 2 == 2)
{
pdeCur = m_pdeHead;
while (pdeCur != NULL)
{
D3DXMatrixIdentity(&mCur);
hr = UpdateFrames(pdeCur->pframeRoot, mCur);
if (FAILED(hr))
return hr;
hr = DrawFrames(pdeCur->pframeRoot, cTriangles);
if (FAILED(hr))
return hr;
pdeCur = pdeCur->pdeNext;
}
}
// End the scene.
m_pd3dDevice->EndScene();
}
return S_OK;
}
Please help.
- Valles
[edited by - valles on July 25, 2003 11:28:54 PM]
[edited by - valles on July 25, 2003 11:31:09 PM]
Trying to draw a primitive with a skinnedmesh.
This code is originally from Skinned Mesh part of DXSDK8 with the minor modification of adding in a single DrawPrimitive added into the render, which is causing the effect pictured below. I set up the animated character to not advance frames, so the mesh is motionless, then I took the camera close to the mesh and zoomed out utlizing some of my own code. The blur is created from each successive frame draw of the character as it is moved further and further from the camera, kind of like a looking down at a deck of cards stacked from smallest to largest with the largest being on the bottom. I don't think the frame is clearing properly.
Anyway, I figured it out, I should have posted the question better. I had to start from the original skinnedmesh and add a single triangle in, creating an original vertexbuffer for the triangle instead of trying to use the one provided for the d3dfont and CreateVertexBuffer alongside the triangle drawprimitive inside of the Render() function.
With it all simple and streamlined it worked! The triangle was moving with one of the body parts, so I understood the next step was to make it so it had its own independent SetTransform which I used for the very first time. YAY!
Once again, thanks to everyone in #gamedev IRC who let me bounce my ideas around.
- Valles
With it all simple and streamlined it worked! The triangle was moving with one of the body parts, so I understood the next step was to make it so it had its own independent SetTransform which I used for the very first time. YAY!
Once again, thanks to everyone in #gamedev IRC who let me bounce my ideas around.
- Valles
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement