Jump to content
  • Advertisement
Sign in to follow this  
HexDump

Fancy thing with stream sources.

This topic is 5056 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I have been writing some code to show debug AABB for my octree, ok no problem, everything is fine. But now when I try to show the real static data, a lot of triangles of different flickering colors are showed, it is really weird. If do not show the AABB the static mesh is rendered ok. I noticed that when I rendered the static data when showing the AABB's it seemed to be using the AABB vertices instead of the static data vertices, this is why I named the post this way. Here is the code to show my AABB:
void CnAABB::Render()
{
	CnRenderer* pRenderer=CnGraphicApp::GetApp()->GetRenderer();
	pRenderer->SetRenderState(D3DRS_CULLMODE,D3DCULL_NONE);
	pRenderer->SetRenderState(D3DRS_FILLMODE,D3DFILL_SOLID);
	pRenderer->SetRenderState(D3DRS_LIGHTING,FALSE);
	
	TLineVertex Vertices[24];
	
	//AABB points U/D->Up/Down L/R->Left/RIght B/F-> Back/Front
	D3DXVECTOR3 ULF, URF, DLF, DRF,ULB, URB, DLB, DRB;
	
	ULF=D3DXVECTOR3(m_pMin->x,m_pMin->y,m_pMax->z);
	URF=D3DXVECTOR3(m_pMax->x,m_pMin->y,m_pMax->z);
	DLF=*m_pMin;
	DRF=D3DXVECTOR3(m_pMax->x,m_pMin->y,m_pMin->z);
	
	ULB=D3DXVECTOR3(m_pMin->x,m_pMax->y,m_pMax->z);
	URB=*m_pMax;
	DLB=D3DXVECTOR3(m_pMin->x,m_pMax->y,m_pMin->z);
	DRB=D3DXVECTOR3(m_pMax->x,m_pMax->y,m_pMin->z);
	
	
	
	pRenderer->GetDevice()->SetFVF(LINE_FVF);
	
	//Parte de arriba
	Vertices[0].vert=ULF;
	Vertices[0].dwColor=0xFFFFFFFF;
	Vertices[1].vert=URF;
	Vertices[1].dwColor=0xFFFFFFFF;
	Vertices[2].vert=URF;
	Vertices[2].dwColor=0xFFFFFFFF;
	Vertices[3].vert=URB;
	Vertices[3].dwColor=0xFFFFFFFF;
	Vertices[4].vert=URB;
	Vertices[4].dwColor=0xFFFFFFFF;
	Vertices[5].vert=ULB;
	Vertices[5].dwColor=0xFFFFFFFF;
	Vertices[6].vert=ULB;
	Vertices[6].dwColor=0xFFFFFFFF;
	Vertices[7].vert=ULF;
	Vertices[7].dwColor=0xFFFFFFFF;
		
	//Parte de Abajo
	Vertices[8].vert=DLF;
	Vertices[8].dwColor=0xFFFFFFFF;
	Vertices[9].vert=DRF;
	Vertices[9].dwColor=0xFFFFFFFF;
	Vertices[10].vert=DRF;
	Vertices[10].dwColor=0xFFFFFFFF;
	Vertices[11].vert=DRB;
	Vertices[11].dwColor=0xFFFFFFFF;
	Vertices[12].vert=DRB;
	Vertices[12].dwColor=0xFFFFFFFF;
	Vertices[13].vert=DLB;
	Vertices[13].dwColor=0xFFFFFFFF;
	Vertices[14].vert=DLB;
	Vertices[14].dwColor=0xFFFFFFFF;
	Vertices[15].vert=DLF;
	Vertices[15].dwColor=0xFFFFFFFF;
	
	//Segmentos para unir las 2 partes
	Vertices[16].vert=ULF;
	Vertices[16].dwColor=0xFFFFFFFF;
	Vertices[17].vert=DLF;
	Vertices[17].dwColor=0xFFFFFFFF;
	Vertices[18].vert=URF;
	Vertices[18].dwColor=0xFFFFFFFF;
	Vertices[19].vert=DRF;
	Vertices[19].dwColor=0xFFFFFFFF;
	Vertices[20].vert=ULB;
	Vertices[20].dwColor=0xFFFFFFFF;
	Vertices[21].vert=DLB;
	Vertices[21].dwColor=0xFFFFFFFF;
	Vertices[22].vert=URB;
	Vertices[22].dwColor=0xFFFFFFFF;
	Vertices[23].vert=DRB;
	Vertices[23].dwColor=0xFFFFFFFF;
	
	
	if(pRenderer->GetDevice()->DrawPrimitiveUP( D3DPT_LINELIST,12, Vertices, sizeof(TLineVertex))!=D3D_OK)
		CnLog::SysLog(eMedLevel,"rendering of AABB failed\r\n");
	
	
	
	pRenderer->SetRenderState(D3DRS_CULLMODE,D3DCULL_CCW);
	pRenderer->SetRenderState(D3DRS_FILLMODE,D3DFILL_SOLID);
}

I think it has anything to do with render states because if I only comment the DrawPrimitiveUp call the static mesh is showed ok. The static mesh use a DrawIndexedPrimitive to render. Thanks in advance, HexDump.

Share this post


Link to post
Share on other sites
Advertisement
Are you calling SetStreamSource() before your static mesh data, after the AABB? Also, SetFVF() as well? If you set a vertex stream and then call DrawPrimitiveUP, that vertex stream will need to be set again before any subsequent DrawPrimitive call.

Share this post


Link to post
Share on other sites
yes of course this is where I render the mesh ( I took out some params from the fuctions).



TPDEVICE pDev=CnGraphicApp::GetApp()->GetRenderer()->GetDevice();


//here I set the material, that will set renderstates

//Set primitives to render
if(pDev->SetFVF(MESH_FVF)!=D3D_OK)
CnLog::SysLog(eMedLevel,"\t\tSetFVF returned an Error [Error]\r\n");


if(pDev->SetIndices()!=D3D_OK)
CnLog::SysLog(eMedLevel,"\t\tSetIndices returned an Error [Error]\r\n");

if(pDev->SetStreamSource( 0,vbPointer , 0, sizeof(TVertex))!=D3D_OK )
CnLog::SysLog(eMedLevel,"\t\tSeStreamSource returned an Error [Error]\r\n");




if(pDev->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,0,0,NumVertices,nPrimitiveCount)!=D3D_OK)
CnLog::SysLog(eMedLevel,"\t\tDrawIndexedPrimitive returned an Error [Error]\r\n");








Thanks in advance,
HexDump.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!