本文整理汇总了C++中Cube::Create方法的典型用法代码示例。如果您正苦于以下问题:C++ Cube::Create方法的具体用法?C++ Cube::Create怎么用?C++ Cube::Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cube
的用法示例。
在下文中一共展示了Cube::Create方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateBodies
void World::CreateBodies()
{
Grid* grid = new Grid();
Cube* cube = new Cube();
cube->Create();
grid->Create();
world.push_back(cube);
world.push_back(grid);
}
示例2: Update
void World::Update (SDL_KeyboardEvent *keyevent)
{
switch(keyevent->keysym.sym)
{
case SDLK_KP_PLUS:
case SDLK_PLUS:
if(keyevent->type==SDL_KEYUP)
{
float x, y, z, size;
x=( (float)rand()/RAND_MAX )* terrain[0]->GetWidth();
z=( (float)rand()/RAND_MAX )* terrain[0]->GetHeight();
size=(float)rand()/(RAND_MAX/1.0)+1.0; // between 1.0 and 2.0
y=terrain[0]->GetMapY(x, z)+size*1.8f;
cout << "creating cube at " << x << " / " << y << " / ";
cout << z << " with size " << size << endl;
Cube *cub = new Cube();
cub->Create(x,y,z,size);
objects.push_back( cub );
/*
objects.push_back( new Sphere(this) );
spheres.back()->Create(x,y,z,size);*/
}
break;
case SDLK_KP_MINUS:
case SDLK_MINUS:
if(keyevent->type==SDL_KEYUP)
{
if(objects.size())
{
delete objects.back();
objects.pop_back();
}
}
break;
case 'p':
if(keyevent->type==SDL_KEYDOWN)
{
printf("current State:\n");
printf("pos.x= %f\tpos.y= %f\tpos.z= %f\n", pos.x, pos.y, pos.z);
cout << "angle.y: " << angle.y << " -> ";
if(drawtop) cout << "drawtop ";
if(drawbuttom) cout << "drawbuttom ";
if(drawright) cout << "drawright ";
if(drawleft) cout << "drawleft ";
cout << endl;
}
break;
case SDLK_SPACE:
if(keyevent->type==SDL_KEYDOWN)
{
// if(yspeed==0)
// yspeed+=jumpvelocity;
}
else
{
}
break;
default:
break;
}
}
示例3: Draw
void World::Draw(void)
{
//std::cout << "Drawing Terrain at " << posx << " / " << posy << " / " << posz << " / ";
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
glLoadIdentity (); // Reset The Modelview Matrix
// --- Go to Cam Pos ---
glRotatef (angle.x, 1.0f, 0.0f, 0.0f); // Rotate On The X-Axis By angle
glRotatef (angle.y, 0.0f, 1.0f, 0.0f); // Rotate On The Y-Axis By angle
glRotatef (angle.z, 0.0f, 0.0f, 1.0f); // Rotate On The Z-Axis By angle
glTranslatef (-this->pos.x, -this->pos.y, -this->pos.z); // Translate to Cam Pos
static const float max = 100.0f;
static const float min = 100.0f;
static Cube mycube;
static float speed = 0.10f;
static float pos[4] = {(float)terrain[0]->GetWidth()*2, max, (float)terrain[0]->GetHeight()*2, 1.0f};
static float amb[4] = {0.01f, 0.01f, 0.01f, 1.0f};
static float dif[4] = {0.5f, 0.5f, 0.5f, 1.0f};
static float spec[4]= {1.0f, 1.0f, 1.0f, 1.0f};
GL_SetLight(pos, amb, dif, spec);
mycube.Create(pos[0],pos[1],pos[2],1.0f);
pos[1]+=speed;
if(pos[1] >= max){
speed = -speed;
pos[1]=max;
}
else if(pos[1] <= min){
speed = -speed;
pos[1]=min;
}
mycube.Draw();
DrawChildren();
if(drawright)
{
glPushMatrix();
glTranslatef(terrain[0]->GetWidth(), 0.0f, 0.0f);
DrawChildren();
glPopMatrix();
}
if(drawleft)
{
glPushMatrix();
glTranslatef(-(terrain[0]->GetWidth()), 0.0f, 0.0f);
DrawChildren();
glPopMatrix();
}
if(drawtop)
{
glPushMatrix();
glTranslatef(0.0f, 0.0f, -terrain[0]->GetHeight());
DrawChildren();
if(drawright)
{
glTranslatef(terrain[0]->GetWidth(), 0.0f, 0.0f);
DrawChildren();
glTranslatef(-terrain[0]->GetWidth(), 0.0f, 0.0f);
}
if(drawleft)
{
glTranslatef(-(terrain[0]->GetWidth()), 0.0f, 0.0f);
DrawChildren();
}
glPopMatrix();
}
if(drawbuttom)
{
glPushMatrix();
glTranslatef(0.0f, 0.0f, terrain[0]->GetHeight());
DrawChildren();
if(drawright)
{
glTranslatef(terrain[0]->GetWidth(), 0.0f, 0.0f);
DrawChildren();
glTranslatef(-terrain[0]->GetWidth(), 0.0f, 0.0f);
}
if(drawleft)
{
glTranslatef(-(terrain[0]->GetWidth()), 0.0f, 0.0f);
DrawChildren();
}
glPopMatrix();
}/**/
glFlush (); // Flush The GL Rendering Pipeline
}