42 CLNode* node, QColor* color) {
50 std::string geometry_id = instance_geometry->
getMeshURL();
56 for (
unsigned int i = 0; i < geometry_object->
getPolygons()->
size(); i++) {
61 bool has_texture =
false;
62 GLuint *texture_id = NULL;
65 const std::string& material_id = polygon_obj->
getMaterialId();
66 if (strcmp(material_id.c_str(),
"") != 0) {
71 renderColor = QColor(210, 210, 210);
80 program->setUniformValue(
"renderTexture", 1.0f);
82 program->setUniformValue(
"renderTexture", 0.0f);
85 program->setUniformValue(
"renderTexture", 0.0f);
86 renderColor = QColor(210, 210, 210);
91 program->setUniformValue(
"renderTexture", 0.0f);
96 bool release_text_coords =
false;
99 release_text_coords =
true;
102 GLfloat* color_array =
new GLfloat[3];
103 color_array[0] = (float)renderColor.red() / 255.0f;
104 color_array[1] = (float)renderColor.green() / 255.0f;
105 color_array[2] = (float)renderColor.blue() / 255.0f;
106 program->setAttributeValue(10, (
const GLfloat*)color_array, 1, 3);
109 const float* opengl_matrix =
MATRIXSTACK->getMatrix().get();
110 QMatrix4x4 qmatrix_model = QMatrix4x4(opengl_matrix);
112 float* raw_matrix = qmatrix_model.data();
115 raw_matrix[12] = raw_matrix[12] * k_QGLGameEditorViewport_SizeFactor;
116 raw_matrix[13] = raw_matrix[13] * k_QGLGameEditorViewport_SizeFactor;
117 raw_matrix[14] = raw_matrix[14] * k_QGLGameEditorViewport_SizeFactor;
119 program->setUniformValue(
"modelMatrix", qmatrix_model);
121 program->enableAttributeArray(0);
122 program->enableAttributeArray(1);
123 program->setAttributeArray(0, vertices, 3);
124 program->setAttributeArray(1, text_coords, 2);
127 glBindTexture(GL_TEXTURE_2D, *texture_id);
130 glDrawArrays(GL_TRIANGLES, 0,
133 if(release_text_coords) {
148 GLfloat color_array[3];
149 color_array[0] = (float)color->red() / 255.0f;
150 color_array[1] = (float)color->green() / 255.0f;
151 color_array[2] = (float)color->blue() / 255.0f;
152 program->setAttributeValue(10, (
const GLfloat*)color_array, 1, 3);
154 GLfloat vertices[] = {
155 (GLfloat)(from.x()), (GLfloat)(from.y()), (GLfloat)(from.z()),
156 (GLfloat)(to.x()), (GLfloat)(to.y()), (GLfloat)(to.z()),
161 program->setUniformValue(
"modelMatrix", mat);
162 program->setUniformValue(
"renderTexture", 0.0f);
163 program->enableAttributeArray(0);
164 program->setAttributeArray(0, vertices, 3);
165 glDrawArrays(GL_LINES, 0, 2);
175 program->setUniformValue(
"modelMatrix", mat);
176 program->setUniformValue(
"renderTexture", 0.0f);
178 GLfloat* color_array = NULL;
179 GLfloat* vertices = NULL;
181 for(std::map<QString, std::vector<bDebugDraw::LineInfo>>::const_iterator it = lines->begin();
184 QColor color = QColor(it->first);
185 color_array =
new GLfloat[3];
186 color_array[0] = (float)color.red() / 255.0f;
187 color_array[1] = (float)color.green() / 255.0f;
188 color_array[2] = (float)color.blue() / 255.0f;
189 program->setAttributeValue(10, (
const GLfloat*)color_array, 1, 3);
192 for(std::vector<bDebugDraw::LineInfo>::const_iterator lineinfo_it = it->second.begin();
193 lineinfo_it != it->second.end();
195 vertices =
new GLfloat[6];
197 vertices[0] = (GLfloat)(line->
from.x());
198 vertices[1] = (GLfloat)(line->
from.y());
199 vertices[2] = (GLfloat)(line->
from.z());
200 vertices[3] = (GLfloat)(line->
to.x());
201 vertices[4] = (GLfloat)(line->
to.y());
202 vertices[5] = (GLfloat)(line->
to.z());
204 program->enableAttributeArray(0);
205 program->setAttributeArray(0, vertices, 3);
206 glDrawArrays(GL_LINES, 0, 2);
CArray< CLPolygon > * getPolygons() const
float * getTriangleMapsConstData()
static bool drawDebugLines(QGLShaderProgram *program, std::map< QString, std::vector< bDebugDraw::LineInfo >> *lines)
CArray< CLInstanceGeometry > * getInstanceGeometries() const
CArray< btVector3 > * getTriangleVertices() const
static std::string & removeOccurrencesOfChar(std::string &original_str, char char_to_remove)
CLMaterial * getMaterialHavingName(const std::string &material_name)
float * getTriangleVerticesConstData()
CLGeometry * getGeometryObjHavingId(const std::string &geometry_obj_id)
CLEffect * getEffectHavingId(const std::string &effect_id)
#define SAFE_RELEASE_ARRAY(x)
const std::string & imageId() const
const std::string & getMeshURL() const
const std::string & instanceEffectURL() const
const std::string & getMaterialId() const
static bool drawLine(QGLShaderProgram *program, btVector3 &from, btVector3 &to, QColor *color)
unsigned int size() const
static bool drawNode(QGLShaderProgram *program, CLScene *collada_scene, CLNode *node, QColor *color)
CLImageDetails * getImageDetailsHavingId(const std::string &image_id)