本文整理汇总了C++中Matrix4::arrayOpenGL方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix4::arrayOpenGL方法的具体用法?C++ Matrix4::arrayOpenGL怎么用?C++ Matrix4::arrayOpenGL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix4
的用法示例。
在下文中一共展示了Matrix4::arrayOpenGL方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw_actor
void draw_actor( void ) {
GLfloat material_Ka[4] = { actor_Ka(0), actor_Ka(1), actor_Ka(2), 1.0 };
GLfloat material_Kd[4] = { actor_Kd(0), actor_Kd(1), actor_Kd(2), 1.0 };
GLfloat material_Ks[4] = { actor_Ks(0), actor_Ks(1), actor_Ks(2), 1.0 };
GLfloat material_Ke[4] = { actor_Ke(0), actor_Ke(1), actor_Ke(2), 1.0 };
GLfloat material_Se = 10;
glPushMatrix();
glMaterialfv(GL_FRONT, GL_AMBIENT, material_Ka);
glMaterialfv(GL_FRONT, GL_DIFFUSE, material_Kd);
glMaterialfv(GL_FRONT, GL_SPECULAR, material_Ks);
glMaterialfv(GL_FRONT, GL_EMISSION, material_Ke);
glMaterialf(GL_FRONT, GL_SHININESS, material_Se);
glLoadMatrixd( actor_transform.arrayOpenGL() );
/*
glBegin(GL_TRIANGLES);
glVertex3d( 1.0, 0.0, 0.0);
glVertex3d(-1.0, 1.0, 0.0);
glVertex3d(-1.0,-1.0, 0.0);
glEnd();
*/
glutSolidTeapot( 1.0 );
glPopMatrix();
}
示例2: draw_motivator
void draw_motivator( ) {
glPushMatrix();
glLoadIdentity();
Matrix4 transform = Matrix4::translationMatrix( motivator.position );
glLoadMatrixd( transform.arrayOpenGL() );
draw_mesh( motivator_mesh );
glPopMatrix();
}
示例3: draw
//------------------------------------------------------------------------------
// Drawing Operations
//------------------------------------------------------------------------------
/// Draws a mesh
void draw( Mesh* mesh, Matrix4& transform ) {
Matrix3 R = transform.rotation();
// backface cull
Vector3 view = scene.camera.position - scene.camera.viewpoint;
for( unsigned int poly_id = 0; poly_id < mesh->polygonCount( ); poly_id++ ) {
Polygon* poly = mesh->polygon( poly_id );
Vector3 normal = R * poly->normal;
if( Vector3::dot( view, normal ) >= 0.0 ) {
Vertex* v = mesh->vertex( poly->getVertex( 0 ) );
Vector3 pt = Vector3( v->position.x(), v->position.y(), v->position.z() );
if( Vector3::dot( scene.camera.position - pt, normal ) >= 0.0 )
poly->backface = true;
else
poly->backface = false;
} else {
poly->backface = false;
}
}
glLoadMatrixd( transform.arrayOpenGL() );
glBegin( GL_TRIANGLES );
for( unsigned int poly_id = 0; poly_id < mesh->polygonCount( ); poly_id++ ) {
// Select the current polygon
Polygon* poly = mesh->polygon( poly_id );
if(BACKFACE_CULL)
if( poly->backface ) continue;
/*
GLfloat *material_Ka, *material_Kd, *material_Ks, *material_Ke, material_Se;
if( poly->material != NULL ) {
material_Ka = (GLfloat*)poly->material->ambient.arrayOpenGL();
material_Kd = (GLfloat*)poly->material->diffuse.arrayOpenGL();
material_Ks = (GLfloat*)poly->material->specular.arrayOpenGL();
material_Ke = (GLfloat*)poly->material->emissive.arrayOpenGL();
material_Se = (GLfloat)poly->material->shininess;
glMaterialfv(GL_FRONT, GL_AMBIENT, material_Ka);
glMaterialfv(GL_FRONT, GL_DIFFUSE, material_Kd);
glMaterialfv(GL_FRONT, GL_SPECULAR, material_Ks);
glMaterialfv(GL_FRONT, GL_EMISSION, material_Ke);
glMaterialf(GL_FRONT, GL_SHININESS, material_Se);
}
*/
glColor3d( 0.6, 0.0, 0.0 );
Vertex *v0, *v1, *v2;
unsigned int verts = poly->numVertices( );
if( verts < 3 ) continue; // sanity check -> malformed poly & bad juju
// the model is not tessellated, so have to tessellate for OpenGL
// If poly is non-convex this won't work, but assume convex.
// Select the first vertex as the root of all triangles in the poly
v0 = mesh->vertex( poly->getVertex( 0 ) );
// Iterate over the rest of the vertices in the polygon up to the n-1 vert
for( unsigned int poly_vert = 1; poly_vert < verts - 1; poly_vert++ ) {
// select the current vertex
v1 = mesh->vertex( poly->getVertex( poly_vert ) );
// and the next vertex (for n-1 case this will be n so closes the poly)
v2 = mesh->vertex( poly->getVertex( poly_vert + 1 ) );
glVertex3d( v0->position.x(), v0->position.y(), v0->position.z() );
glNormal3d( v0->normal.x(), v0->normal.y(), v0->normal.z() );
//glNormal3d( poly->normal.x(), poly->normal.y(), poly->normal.z() );
glVertex3d( v1->position.x(), v1->position.y(), v1->position.z() );
glNormal3d( v1->normal.x(), v1->normal.y(), v1->normal.z() );
//glNormal3d( poly->normal.x(), poly->normal.y(), poly->normal.z() );
glVertex3d( v2->position.x(), v2->position.y(), v2->position.z() );
glNormal3d( v2->normal.x(), v2->normal.y(), v2->normal.z() );
//glNormal3d( poly->normal.x(), poly->normal.y(), poly->normal.z() );
}
}
glEnd();
}