Jump to content
  • Advertisement
Sign in to follow this  
zauron

Drawing bounding boxes.

This topic is 5085 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

I am working on my collissions and would like to see the bounding boxes in my app. At the moment i have a std::vector with my objects, and i call draw on all of them. Yhis works great they are all drawn, but when i set draw on my bounding box, only the first is drawn.
void Platform::draw(){
  // plassering
  D3DXMATRIX matWorld;
  D3DXMatrixTranslation( &matWorld, pos.x,pos.y,pos.z );
  g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
  
  g_pd3dDevice->SetMaterial( &mtrl );
  
  mesh->DrawSubset( 0 );

  bbox.draw();  <- this is where i call it, only first call is drawn

	// plassering
  D3DXMatrixIdentity(&matWorld);
  g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
}

bBox::bBox(){
  g_pd3dDevice->CreateVertexBuffer(sizeof(Vertex) * 24, 0, VERTEXFORMAT, D3DPOOL_DEFAULT, &vb, NULL);
}

void bBox::draw(){
  int i = 0;
  Vertex *lp_v;
  vb->Lock(0, 0, (void**)&lp_v, D3DLOCK_DISCARD);

  lp_v[i++].position = center + left + up - in;
  lp_v[i++].position = center - left + up - in;
  lp_v[i++].position = center + left + up - in;
  lp_v[i++].position = center + left - up - in;
  lp_v[i++].position = center - left - up - in;
  lp_v[i++].position = center - left + up - in;
  lp_v[i++].position = center - left - up - in;
  lp_v[i++].position = center + left - up - in;

  lp_v[i++].position = center + left + up + in;
  lp_v[i++].position = center - left + up + in;
  lp_v[i++].position = center + left + up + in;
  lp_v[i++].position = center + left - up + in;
  lp_v[i++].position = center - left - up + in;
  lp_v[i++].position = center - left + up + in;
  lp_v[i++].position = center - left - up + in;
  lp_v[i++].position = center + left - up + in;

  lp_v[i++].position = center + left + up + in;
  lp_v[i++].position = center + left + up - in;
  lp_v[i++].position = center + left - up + in;
  lp_v[i++].position = center + left - up - in;
  lp_v[i++].position = center - left - up + in;
  lp_v[i++].position = center - left - up - in;
  lp_v[i++].position = center - left + up + in;
  lp_v[i++].position = center - left + up - in;
  
  vb->Unlock();
  
  g_pd3dDevice->SetStreamSource(0, vb, 0, sizeof(Vertex));

  g_pd3dDevice->SetFVF( VERTEXFORMAT );

  g_pd3dDevice->DrawPrimitive( D3DPT_LINELIST, 0, 12 );
}

Wondering why this happens,any ideas?

Share this post


Link to post
Share on other sites
Advertisement
Maybe i shouldgive more info. I am sure the draw function in the bounding box class gets called. But it just wont render anything after the first one.

Platforms and boxes


Removed the rendering of the platforms


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!