Jump to content

  • Log In with Google      Sign In   
  • Create Account

Bullet physics wireframe drawn in a wrong place


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 LeeBrowm   Members   -  Reputation: 127

Like
0Likes
Like

Posted 09 August 2014 - 03:23 AM

Hello,

I'm trying to get my Bullet physics debug working properly. And I am experiencing a problem while drawing wireframe - it gets drawn in a wrong place. It looks like the problem is purely of mathematical origin but I just don't know how to get around it. I've recorded a video showing the problem.

http://youtu.be/1qn5vNwkiHA

 

My guess is that it is related to the fact that I draw all the objects using VAO, but the wireframe drawLine function is umplemented using glBegin(GL_LINES)-glEnd.

 

 

Here is my draw function:


void World::Draw()
{
    glClearColor(0.1f,0.4f,0.9f,1.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glm::mat4 VP =m_camera->GetViewProjection();
    for(std::list<Object*>::iterator it = m_list.begin(), end =m_list.end(); it !=end; ++it) {
        glActiveTexture(GL_TEXTURE0);
        glBindTexture(GL_TEXTURE_2D, *(*it)->TextureIDPtr());
        m_shader.Update((*it)->TransformMatrixPtr(),&VP);
        for(int k=0;k<(*it)->ModelPtr()->numMeshes;k++) {
            glBindVertexArray((*it)->ModelPtr()->Meshes[k].m_VAOID);
            glDrawElements(GL_TRIANGLES, (*it)->ModelPtr()->Meshes[k].m_drawCount, GL_UNSIGNED_INT, 0);
        }
        glBindVertexArray(0);
    }
    m_dynamicsWorld->debugDrawWorld();
}

m_dynamicsWorld->debugDrawWorld() in it's turn calls the following function

void bulletDebugDrawer::drawLine(const btVector3& from,const btVector3& to,const btVector3& color)
{
    glBegin(GL_LINES);
            glColor3f(color.getX(), color.getY(), color.getZ());
            glVertex3d(from.getX(), from.getY(), from.getZ());
            glColor3f(color.getX(), color.getY(), color.getZ());
            glVertex3d(to.getX(), to.getY(), to.getZ());
    glEnd();
}

So I would greatly appreciate any help or hint on how to fix this thinghappy.png

 



Sponsor:

#2 Sponji   Members   -  Reputation: 1250

Like
1Likes
Like

Posted 09 August 2014 - 09:30 AM

Do you set the projection and view matrices somewhere?

 

Maybe something like this:

void World::Draw() {
	// ... 

	glMatrixMode(GL_PROJECTION);
	glLoadMatrixf(glm::value_ptr(projection_matrix));

	glMatrixMode(GL_MODELVIEW);
	glLoadMatrixf(glm::value_ptr(view_matrix));

	m_dynamicsWorld->debugDrawWorld();
}

Derp




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS