43 lines
1.2 KiB
C++
43 lines
1.2 KiB
C++
#include "physicsdebugnode.h"
|
|
#include "SparrowRenderer/mesh.h"
|
|
#include "SparrowRenderer/phongmaterial.h"
|
|
|
|
PhysicsDebugNode::PhysicsDebugNode() :
|
|
MeshNode(new Mesh())
|
|
{
|
|
PhongMaterial* mat = new PhongMaterial();
|
|
mat->emission = glm::vec3(1, 0, 0);
|
|
mat->diffuse = glm::vec3(0);
|
|
mat->specular = glm::vec3(0);
|
|
|
|
m_geometry.mesh->setMaterial(mat);
|
|
m_geometry.mesh->setPrimitiveType(GL_LINES);
|
|
m_geometry.mesh->setWireframe(true);
|
|
|
|
glm::vec3 pos1(0, 1, 0);
|
|
glm::vec3 pos2(0, 0, 0);
|
|
glm::vec3 color(1, 0, 0);
|
|
m_geometry.mesh->addVertex(pos1, color);
|
|
m_geometry.mesh->addVertex(pos2, color);
|
|
m_geometry.mesh->updateFlags();
|
|
}
|
|
|
|
void PhysicsDebugNode::drawLine(const btVector3& from, const btVector3& to, const btVector3& color)
|
|
{
|
|
glm::vec3 glColor(color.x(), color.y(), color.z());
|
|
m_geometry.mesh->addVertex(glm::vec3(from.x(), from.y(), from.z()), glColor);
|
|
m_geometry.mesh->addVertex(glm::vec3(to.x(), to.y(), to.z()), glColor);
|
|
}
|
|
|
|
void PhysicsDebugNode::flushLines()
|
|
{
|
|
// a little heavy, but it's a debug mode so it shouldn't be a problem
|
|
m_geometry.mesh->initGL();
|
|
}
|
|
|
|
void PhysicsDebugNode::clearBuffers()
|
|
{
|
|
m_geometry.mesh->positions3D.clear();
|
|
m_geometry.mesh->normals.clear();
|
|
}
|