Sign in to follow this  

Drawing bounding boxes.

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

This topic is 4743 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this