void Ship::render(GLuint colorLocation) { Entity::render(colorLocation); glPushMatrix(); vec3 p = m_body->getPosition(); glTranslatef(p.x, p.y, p.z); mat3x3 q = transpose(toRotMat(m_body->getOrientation())); float rot[16] = { q[0][0], q[0][1], q[0][2], 0.0f, q[1][0], q[1][1], q[1][2], 0.0f, q[2][0], q[2][1], q[2][2], 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, }; glMultMatrixf(rot); glUniform3f(colorLocation, 0, 1, 1); renderBrick(m_base, m_base, colorLocation, g_tick++); glPopMatrix(); }
void generateRenderBricks( const ConstCacheObjects& renderNodes, RenderBricks& renderBricks ) { renderBricks.reserve( renderNodes.size( )); BOOST_FOREACH( const ConstCacheObjectPtr& cacheObject, renderNodes ) { const ConstTextureObjectPtr texture = boost::static_pointer_cast< const TextureObject >( cacheObject ); RenderBrickPtr renderBrick( new RenderBrick( texture->getLODNode(), texture->getTextureState( ))); renderBricks.push_back( renderBrick ); } }
void generateRenderBricks( const DashNodeVector& renderNodeList, RenderBricks& renderBricks ) { BOOST_FOREACH( const dash::NodePtr& dashNode, renderNodeList ) { const DashRenderNode dashRenderNode( dashNode ); const ConstTextureObjectPtr texture = boost::static_pointer_cast< const TextureObject >( dashRenderNode.getTextureObject( )); RenderBrickPtr renderBrick( new RenderBrick( texture->getLODNode(), texture->getTextureState( ))); renderBricks.push_back( renderBrick ); } }
void Ship::renderBrick(Brick* brick, Brick* base, GLuint colorLocation, int tick) { brick->tick = tick; for (int j = 0; j < brick->numConnections; ++j) { Connection* connection = brick->connections + j; //for (int axis = Z; false; ++axis) { int axis = m_minAxis; for (int i = 0; i < 2; ++i) { Joint* joint = connection->joints[axis] + i; if (joint->flow != 0) { glLineWidth(10.0f * joint->flow); glBegin(GL_LINES); glVertex3f(brick->pos[0], brick->pos[1], brick->pos[2]); glVertex3f(connection->other->pos[0], connection->other->pos[1], connection->other->pos[2]); glEnd(); glLineWidth(1); } //glLineWidth(connection->joint->capacity * 10.0f); //glBegin(GL_LINES); //glVertex3f(0.5f * (brick->pos[0] + connection->other->pos[0]), 0.5f*(brick->pos[1] + connection->other->pos[1]), 0.5f * (brick->pos[2] + connection->other->pos[2])); //glVertex3f(0.5f * (brick->pos[0] + connection->other->pos[0]), brick->pos[1] , 0.5f * (brick->pos[2] + connection->other->pos[2])); //glEnd(); //glLineWidth(1); for (int i = 0; i < brick->numBlocking; ++i) { glBegin(GL_LINES); glVertex3f(brick->pos[0], brick->pos[1], brick->pos[2]); glVertex3f((*brick->blocking[i])->connection->brick->pos[0], (*brick->blocking[i])->connection->brick->pos[1], (*brick->blocking[i])->connection->brick->pos[2]); glEnd(); } if (joint->capacity > 0) { glLineWidth(joint->capacity * 5.0f); glBegin(GL_LINES); if (axis == X) { int min = ong_MIN(brick->pos[2], joint->connection->other->pos[2]) - 1 + abs(brick->pos[2] - joint->connection->other->pos[2]); int max = ong_MAX(brick->pos[2], joint->connection->other->pos[2]) + 1 - abs(brick->pos[2] - joint->connection->other->pos[2]); glVertex3f(joint->data->fulcrum, joint->data->y, min); glVertex3f(joint->data->fulcrum, joint->data->y, max); } else if (axis == Z) { int min = ong_MIN(brick->pos[0], joint->connection->other->pos[0]) - 2 + abs(brick->pos[0] - joint->connection->other->pos[0]); int max = ong_MAX(brick->pos[0], joint->connection->other->pos[0]) + 2 - abs(brick->pos[0] - joint->connection->other->pos[0]); glVertex3f(min, joint->data->y, joint->data->fulcrum); glVertex3f(max, joint->data->y, joint->data->fulcrum); } glEnd(); glLineWidth(1); } } } if (connection->other->tick != tick) renderBrick(connection->other, base, colorLocation, tick); } if (brick == base) { glUniform3f(colorLocation, 1, 0, 1); glPointSize(10.0f); glBegin(GL_POINTS); glVertex3f(brick->pos[0], brick->pos[1], brick->pos[2]); glEnd(); glPointSize(1.0f); glUniform3f(colorLocation, 0, 1, 1); } }