本文整理汇总了C++中ObjModel::draw方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjModel::draw方法的具体用法?C++ ObjModel::draw怎么用?C++ ObjModel::draw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjModel
的用法示例。
在下文中一共展示了ObjModel::draw方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawRoad
void drawRoad(int i)
{
glPushMatrix();
glTranslatef(0, -1.0f, stepObj[i].z);
glRotatef(90.0f, 0.0f, 1.0f, 0.0f);
if(stepObj[i].type == 0){
road.draw();
drawCar(10.0f, 0, 0.09f, i);
}else if(stepObj[i].type == 1){
grass.draw();
}
glPopMatrix();
}
示例2: display
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// clear the screen - any drawing before here will not display
glLoadIdentity();
// set up the camera here
camera.setCamera();
// camera is set up - any drawing before here will display incorrectly
// Draw Skybox
glPushMatrix();
glTranslatef(camera.getPosition().x,
camera.getPosition().y,
camera.getPosition().z);
glDepthMask(GL_FALSE);
skybox.draw();
glDepthMask(GL_TRUE);
glPopMatrix();
// Draw Saturn
glPushMatrix();
glTranslatef(saturnInfo.x, 0.f, saturnInfo.z);
glScalef(saturnInfo.radius, saturnInfo.radius, saturnInfo.radius);
saturn.draw();
glPopMatrix();
// Draw Moons
for (int i = 0; i < 10; i++)
{
glPushMatrix();
glTranslatef(moonInfo[i].x, 0.f, moonInfo[i].z);
glScalef(moonInfo[i].radius, moonInfo[i].radius, moonInfo[i].radius);
moons[i].draw();
glPopMatrix();
}
// Draw rings
glPushMatrix();
glTranslatef(ringInfo.x, 0.f, ringInfo.z);
glScalef(ringInfo.radius, ringInfo.radius, ringInfo.radius);
ring.draw();
glPopMatrix();
// send the current image to the screen - any drawing after here will not display
glutSwapBuffers();
}
示例3: drawCar
void drawCar(float y, float z, float scale, int i)
{
glPushMatrix();
glTranslatef(0, 1, count_steps[i]);
glScalef(scale,scale,scale);
//glRotatef(90.0f, 0.0f, 1.0f, 0.0f);
car1.draw();
glPopMatrix();
}
示例4: player
void player()
{
glPushMatrix();
glTranslatef(playerX, playerY, playerZ);
glRotatef(playerAngle, 0.0f, 1.0f, 0.0f);
glScalef(playerSX, playerSY, playerSZ);
player1.draw();
glPopMatrix();
}
示例5: display
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
gluLookAt(2.0, 3.0, 4.0,
0.0, 0.0, 0.0,
0.0, 1.0, 0.0);
// display positive X, Y, and Z axes near origin
glBegin(GL_LINES);
glColor3d(1.0, 0.0, 0.0);
glVertex3d(0.0, 0.0, 0.0);
glVertex3d(2.0, 0.0, 0.0);
glColor3d(0.0, 1.0, 0.0);
glVertex3d(0.0, 0.0, 0.0);
glVertex3d(0.0, 2.0, 0.0);
glColor3d(0.0, 0.0, 1.0);
glVertex3d(0.0, 0.0, 0.0);
glVertex3d(0.0, 0.0, 2.0);
glEnd();
// draw a purple wireframe cube
glColor3d(1.0, 0.0, 1.0);
glPushMatrix();
glTranslated(0.0, 0.0, 0.0);
glRotated(45, 0.0, 1.0, 0.0);
glScaled(1.0, 1.0, 1.0);
glutWireCube(1.0);
glPopMatrix();
glPushMatrix();
glTranslated(0.0, 0.0, 0.0);
// glRotated(45, 0.0, 1.0, 0.0);
glScaled(0.005, 0.005, 0.005);
bucket.draw();
glPopMatrix();
glutSwapBuffers();
}
示例6: whale_model
void whale_model()
{
//glMatrixMode(GL_MODELVIEW);
GLUquadricObj* Sphere;
Sphere=gluNewQuadric();
float theta=0;
if(v_whale_z<0)
{
theta = 3.14 + atan(v_whale_x/v_whale_z);
}
else if (v_whale_z>0 )
{
theta = atan(v_whale_x/v_whale_z);
}
else
{
if(v_whale_x>0)
{
theta= 3.14/2;
}
else if(v_whale_x<0)
{
theta = (3 * 3.14) / 2;
}
}
theta = (theta * 180) / 3.14;
float r;
r = sqrt(powf(v_whale_x,2)+powf(v_whale_z,2));
float pi;
if(v_whale_y!=0 && r>0)
{
pi=atan(v_whale_y/r);
}
else if(r==0)
{
if(p_whale_y>0)
{
pi=3.14/2;
}
else if(p_whale_y<0)
{
pi = (3.14 * 3)/2;
}
}
pi = (pi * 180) / 3.14;
submarine1 sub2;
GLUquadricObj *Spher;
Spher = gluNewQuadric();
glPushMatrix();
glTranslatef(p_whale_x, p_whale_y, p_whale_z); // unneeded since default position is (0, 0, 0)
/*glBegin(GL_LINES);
glVertex3d(0, 0, 0);
glVertex3d(vx[i], vy[i], vz[i]);
glEnd();*/
glRotatef(theta, 0.0, 1.0, 0.0); // unneeded since default rotation is 0 degrees
glRotatef(pi, -1.0, 0.0, 0.0);
glScalef(7.0, 7.0, 7.0); // unneeded since default scaling is 1 in X, Y, and Z
glRotatef(90, 0.0, 1.0, 0.0);
whale_body.draw();
if(sphere==true)
{
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4f(sub2.red, sub2.green, sub2.blue, 0.2f);
gluSphere(Spher,1, 10, 10);
glDisable(GL_BLEND);
}
glPopMatrix();
}
示例7: draw
void draw()
{
glClearColor(1, 1, 1, 1);
glLoadIdentity();
float x1, y1, z1, x2=-65.147f, y2=80.219f, z2=12.301f;
static int index = 0;
TheoraVideoFrame* f=clip->getNextFrame();
if (f)
{
index = (int)f->getFrameNumber();
glBindTexture(GL_TEXTURE_2D,tex_id);
unsigned char* buffer = f->getBuffer();
int x, len = f->getWidth() * f->getHeight() * 3;
for (int i = 0; i < len; i++)
{
x = (*buffer) * 0.8f + 255 * 0.2f;
if (x > 255) *buffer = 255;
else *buffer = x;
buffer++;
}
glTexSubImage2D(GL_TEXTURE_2D,0,0,0,f->getWidth(),f->getHeight(),GL_RGB,GL_UNSIGNED_BYTE,f->getBuffer());
clip->popFrame();
}
x1 = camera_pos[index].x; y1 = camera_pos[index].y; z1 = camera_pos[index].z;
gluLookAt(x1, z1, -y1, x2, z2, -y2, 0,1,0);
//gluLookAt(x1, y1, z1, x2, z2, -y2, 0,1,0);
glBlendFunc(GL_ONE,GL_ZERO);
glEnable(GL_CULL_FACE);
if (diffuse_enabled) glEnable(GL_TEXTURE_2D);
else glDisable(GL_TEXTURE_2D);
room.draw();
glDisable(GL_CULL_FACE);
if (lighting_enabled)
{
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,tex_id);
glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glDisable(GL_DEPTH_TEST);
glBlendFunc(GL_DST_COLOR, GL_ZERO);
glBegin(GL_QUADS);
glTexCoord2f( 0, 4 / 1024.0f); glVertex3f(-1, 1, 0);
glTexCoord2f(800 / 1024.0f, 4 / 1024.0f); glVertex3f( 1, 1, 0);
glTexCoord2f(800 / 1024.0f, 604 / 1024.0f); glVertex3f( 1,-1, 0);
glTexCoord2f( 0, 604 / 1024.0f); glVertex3f(-1,-1, 0);
glEnd();
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glEnable(GL_DEPTH_TEST);
}
}
示例8: draw
void draw()
{
/**
* Draws the 3D scene within the view volume
*/
int i,j;
nfood=0;
prevFrameTime = curFrameTime;
curFrameTime = glutGet(GLUT_ELAPSED_TIME); //Determines the time gap between two continuous frame to enable frame independent animation
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW); //Switch to the drawing perspective
glLoadIdentity(); //Reset the drawing perspective
glPushMatrix();
camera();
//glTranslatef(0.0f,0.0f,-100.0f);
GLfloat light_position[] = { 0.0, 0.0, 1.0, 0.0 };
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
//Set material for pac and draw the pac
GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat mat_shininess[] = {50.0};
glTranslatef(-gridWidthby2, -gridHeightby2,-100.0f);
glPushMatrix();
glTranslatef(-gridCellSide/2,-gridCellSide/2,-gridCellSide/2);
glColor4f(0.3,0.34,0.32,1.0);
glBegin(GL_QUADS);
glVertex3f(-gridCellSide,-gridCellSide,0);
glVertex3f(-gridCellSide,gridHeightby2*2+gridCellSide,0);
glVertex3f(gridWidthby2*2+gridCellSide,gridHeightby2*2+gridCellSide,0);
glVertex3f(gridWidthby2*2+gridCellSide,0-gridCellSide,0);
glEnd();
glPopMatrix();
glPushMatrix();
/*
In the following lines of code, we translate the PAC, and rotate it according to the direction of the PAC
*/
glTranslatef(pacx,pacy,0);
if(!minionEnabled){
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
glColor4f(0.75f,0.75f,0.0f,1.0f);
glutSolidSphere(PACSIZE,50,50);
}
else{
glDisable(GL_COLOR_MATERIAL);
glRotatef(90.0f,1.0,0.0,0.0);
if(pacCurDir == GLUT_KEY_LEFT) {
if(pacAngle <= 270 - angleChange || pacAngle >= 270 + angleChange){
if(pacAngle<=90 || pacAngle>270){
pacAngle-=angleChange;
if(pacAngle<0)
pacAngle+=360;
}
else
pacAngle = (pacAngle+angleChange)%360;
}
glRotatef((float)pacAngle,0.0,1.0,0.0);
}
else if(pacCurDir == GLUT_KEY_RIGHT){
if(pacAngle <= 90 - angleChange || pacAngle >= 90 + angleChange){
if(pacAngle<90 || pacAngle>=270){
pacAngle = (pacAngle+angleChange)%360;
}
else
pacAngle = (pacAngle-angleChange);
if(pacAngle<0)
pacAngle+=360;
}
glRotatef((float)pacAngle,0.0,1.0,0.0);
}
else if(pacCurDir == GLUT_KEY_UP){
if(pacAngle <= 180 - angleChange || pacAngle >= 180 + angleChange){
if(pacAngle<=359 && pacAngle>180){
pacAngle = (pacAngle-angleChange);
if(pacAngle<0)
pacAngle+=360;
}
else
pacAngle = (pacAngle+angleChange)%360;
}
glRotatef((float)pacAngle,0.0,1.0,0.0);
}
else if(pacCurDir == GLUT_KEY_DOWN){
if(pacAngle <= 0 - angleChange || pacAngle >= 0 + angleChange){
if(pacAngle<=180 && pacAngle>0){
pacAngle = (pacAngle-angleChange);
if(pacAngle<0)
pacAngle+=360;
}
else
pacAngle = (pacAngle+angleChange)%360;
}
glRotatef((float)pacAngle,0.0,1.0,0.0);
}
//.........这里部分代码省略.........