本文整理汇总了C++中Plane::Draw方法的典型用法代码示例。如果您正苦于以下问题:C++ Plane::Draw方法的具体用法?C++ Plane::Draw怎么用?C++ Plane::Draw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Plane
的用法示例。
在下文中一共展示了Plane::Draw方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DisplayPlane
void DisplayPlane()
{
Window * window = Window::FindCurrentWindow(windows);
if (window->handle == BAD_GL_VALUE)
return;
glViewport(0, 0, window->size.x, window->size.y);
vec4 crimson(0.6f , 0.0f , 0.0f , 1.0f);
vec3 ambient = vec3(0.0f , 0.0f , 0.0f);
vec3 specular = vec3(1.0f , 1.0f , 1.0f);
vec3 diffuse = vec3(0.0f , 0.0f , 0.8f);
glClearColor(crimson.r , crimson.g , crimson.b , crimson.a);
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
mat4 model_matrix = rotate(mat4() , radians(window->LocalTime() * 0.0f) , vec3(0.0f , 1.0f , 0.0f));
model_matrix = scale(model_matrix , vec3(3.0f , 3.0f , 3.0f));
mat4 lightMatrix = rotate(mat4() , radians(window->LocalTime() * 0.0f) , vec3(0.0f , 1.0f , 0.0f));
vec3 light_pos = vec3(lightMatrix * vec4(0.0f , 0.0f , 10000.0f , 1.0f));
mat4 view_matrix = lookAt(vec3(0.0f , 0.0f , 10.0f) , vec3(0.0f , 0.0f , 0.0f) , vec3(0.0f , 1.0f , 0.0f));
mat4 projection_matrix = perspective(radians(window->fovy) , window->aspect , window->near_distance , window->far_distance);
phong_shader.Use(model_matrix , view_matrix , projection_matrix);
phong_shader.SetMaterial(diffuse , specular , 64.0f , ambient);
phong_shader.SetLightPosition(light_pos);
phong_shader.SelectSubroutine(PhongShader::PHONG_WITH_TEXTURE);
phong_shader.EnableTexture(textures[0] , 0);
plane2.Draw(false);
phong_shader.UnUse();
if (window->draw_normals)
{
constant_shader.Use(model_matrix, view_matrix, projection_matrix);
constant_shader.SetMaterial(diffuse, specular, 64.0f, vec3(1.0f, 1.0f, 1.0f));
plane2.Draw(true);
constant_shader.UnUse();
}
glutSwapBuffers();
plane2.UpdateValues(TestUpdatePlane , window->LocalTime() , (void *) &plane2.Dimensions());
}
示例2: main
int main () {
srand(time(NULL));
FsOpenWindow(0,0,600, 800,1);
glClearColor(0, 0, 0, 1);
glShadeModel(GL_SMOOTH);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
textureInit();
WeaponUpgrade::LoadTexture("pic/red.png", "pic/green.png", "pic/blue.png");
Plane *plane;
plane = new WeaponUpgrade();
bool running = true;
while(running)
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
FsPollDevice();
int key=FsInkey();
int lb, mb, rb, mx, my;
int mouse = FsGetMouseEvent(lb, mb, rb, mx, my);
if(FSKEY_ESC==key)
{
running=false;
}
plane->Draw();
plane->Move(1.0);
if (((Prize *)plane)->Dead()) {
delete plane;
plane = new WeaponUpgrade();
}
FsSwapBuffers();
FsSleep(25);
}
return 0;
}
示例3: main
int main(){
Vector2 startPosition(300, 500);
Vector2 startDirection(0, -1);
/* This list is used to store all user emmitted active missiles */
MissileList enemy2Missiles;
MissileList playerMissiles;
/* Create the thunder */
Thunder thunder(startPosition, startDirection);
thunder.setVelocity(5);
thunder.SwitchWeapon(BULLET, playerMissiles);
Plane *player;
player = &thunder;
/* Create the boss */
LazerEnemy enemy2(Vector2(300, 0), Vector2(0,1));
enemy2.Init(enemy2Missiles);
enemy2.setVelocity(15);
Plane *enemy;
enemy = &enemy2;
FsOpenWindow(0,0,WINDOW_WID,WINDOW_HEI,1);
glClearColor(0.1, 0.1, 0.1, 1);
bool running = true;
int i = 0;
int cntDown = 0;
while(running)
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
FsPollDevice();
int key=FsInkey();
int lb, mb, rb, mx, my;
int mouse = FsGetMouseEvent(lb, mb, rb, mx, my);
if(FSKEY_ESC==key) {
running=false;
break;
} else if (FSKEY_UP == key) {
/* UP for power up */
((Thunder *)player)->PowerUp(playerMissiles);
}
if (FSMOUSEEVENT_RBUTTONDOWN == mouse) {
/* Right click for switch between 3 types of weapons */
i = (i+1) % 3;
((Thunder *)player)->SwitchWeapon((MissileType)i, playerMissiles);
}
/* Thunder: shoot and cool down weapon. */
player->Shoot(mouse, playerMissiles);
player->CoolDown();
/* Thunder: move and draw. */
player->Move(1.0);
player->Draw();
/* Draw the enemy */
enemy->Aim(player);
printf("before move\n");
enemy->Move(0.4);
printf("after move\n");
enemy->Draw();
/* Enemy fire */
((LazerEnemy *)enemy)->Shoot(enemy2Missiles);
enemy->CoolDown();
if (enemy->CheckHit(playerMissiles) == 1) {
((LazerEnemy *)enemy)->Disappear(enemy2Missiles);
cntDown = 100;
}
/* Stay for a while after boss die */
if (cntDown > 0) {
cntDown--;
if (cntDown == 0)
running = false;
}
/* traverse the missiles list, move missile */
MissileNode *node;
node = enemy2Missiles.getFront();
while(node) {
node->dat->Move(1.0);
if (!node->dat->CheckInWindow()) {
node = enemy2Missiles.Delete(node);
} else {
node = node->next;
}
}
node = playerMissiles.getFront();
while(node) {
node->dat->Move(1.0);
//.........这里部分代码省略.........
示例4: DisplayGrid
void DisplayGrid()
{
//cout << "dg\n";
Window * window = Window::FindCurrentWindow(windows);
if (window->handle == BAD_GL_VALUE)
return;
glViewport(0 , 0 , window->size.x , window->size.y);
vec4 crimson(0.6f , 0.0f , 0.0f , 1.0f);
vec3 ambient = vec3(0.0f , 0.0f , 0.0f);
vec3 specular = vec3(1.0f , 1.0f , 1.0f);
vec3 diffuse = vec3(0.0f , 0.0f , 0.8f);
glClearColor(crimson.r , crimson.g , crimson.b , crimson.a);
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
vector<Constellation::PositionData> & pd = gc.GetPositionData();
mat4 s = scale(mat4() , vec3(50.0f , 50.0f , 1.0f));
mat4 view_matrix = lookAt(vec3(0.0f , 0.0f , 150.0f) , vec3(0.0f , 0.0f , 0.0f) , vec3(0.0f , 1.0f , 0.0f));
mat4 projection_matrix = perspective(radians(window->fovy) , window->aspect , window->near_distance , window->far_distance);
mat4 r = rotate(mat4() , radians(window->LocalTime() * 0.0f) , vec3(0.0f , 1.0f , 0.0f));
for (vector<Constellation::PositionData>::iterator iter = pd.begin(); iter < pd.end(); iter++)
{
mat4 model_matrix = rotate(mat4() , radians(window->LocalTime() * 20.0f) , vec3(0.0f , 1.0f , 0.0f));
model_matrix = translate(model_matrix , vec3(s * vec4((*iter).location , 1.0f)));
// Beginning of orientation code.
//
// There is an assumption here (we are aligning z axes) that the shape you're building have
// a natural facing down the z axis.
//
// The following orients the object's z axis along the axis held in outward_direction_vector.
// target_dir gets that value. The difference in direction from the z axis to the desired direction
// is captured by the dot product. The angle is retrieved with the acos. Then, if there's anything
// to do (I suspect the if statement is NOT needed), a rotation axis is made by the cross product
// (rotating about it will swing the z axes around). Finally, the rotation is done.
vec3 target_dir = normalize((*iter).outward_direction_vector);
float rot_angle = acos(dot(target_dir , vec3(0.0f, 0.0f, 1.0f)));
if (fabs(rot_angle) > glm::epsilon<float>())
{
vec3 rot_axis = normalize(cross(target_dir , vec3(0.0f, 0.0f, 1.0f)));
model_matrix = rotate(model_matrix, rot_angle , rot_axis);
}
// End of orientation code.
model_matrix = scale(model_matrix , vec3(2.0f, 2.0f, 1.0f));
phong_shader.Use(model_matrix , view_matrix , projection_matrix);
phong_shader.SetMaterial(diffuse , specular , 64.0f , ambient);
phong_shader.SetLightPosition(vec3(0.0f , 0.0f , 1000.0f));
phong_shader.SelectSubroutine(PhongShader::PHONG_WITH_TEXTURE);
phong_shader.EnableTexture(textures[1] , 0);
plane2.Draw(false);
phong_shader.UnUse();
if (window->draw_normals)
{
constant_shader.Use(model_matrix , view_matrix , projection_matrix);
constant_shader.SetMaterial(diffuse , specular , 64.0f , vec3(1.0f , 1.0f , 1.0f));
plane2.Draw(true);
constant_shader.UnUse();
}
// Animate the rotation of the objects within the grid.
(*iter).outward_direction_vector = vec3(r * vec4((*iter).outward_direction_vector, 1.0f));
}
glutSwapBuffers();
}
示例5: DrawScene
void DrawScene(Window * window)
{
phong_shader.GLReturnedError("DrawScene() - entering");
#ifdef MOVE
mat4 m = rotate(mat4() , radians(window->LocalTime() * 30.0f) , vec3(0.0f , 1.0f , 0.2f));
m = translate(m, vec3(0.0f, 11.5f * cos(window->LocalTime() * 0.5f) + 2.0f, 11.5f * sin(window->LocalTime() * 0.5f) + 2.0f));
#else
mat4 m;
#endif // MOVE
mat4 view_matrix = lookAt(vec3(m * vec4(eye, 1.0f)), cop, up);
mat4 model_matrix;
mat4 projection_matrix = perspective(radians(window->fovy), window->aspect, window->near_distance, window->far_distance);
vec3 z_axis = vec3(0.0f, 0.0f, 1.0f);
vec3 y_axis = vec3(0.0f, 1.0f, 0.0f);
vec3 ambient = vec3(0.1f, 0.1f, 0.1f);
vec3 specular = vec3(1.0f, 1.0f, 1.0f);
float c_offset = radians(45.0f);
glViewport(0, 0, window->size.x, window->size.y);
const int count_of_shapes = 4;
for (unsigned int i = 0; i < instances.size(); i++)
{
model_matrix = translate(mat4(), instances[i].position);
model_matrix = rotate(model_matrix, radians(window->LocalTime() * instances[i].rate) + instances[i].offset, y_axis);
if (i % count_of_shapes == 3)
model_matrix = scale(model_matrix, vec3(0.25f, 0.25f, 0.25f));
phong_shader.Use(model_matrix, view_matrix, projection_matrix);
phong_shader.SetMaterial(instances[i].diffuse, specular, 32.0f, ambient);
phong_shader.SetLightPosition(vec3(0.0f, 0.0f, 1000.0f));
switch (i % count_of_shapes)
{
case 0:
disc1.Draw(false);
break;
case 1:
disc3.Draw(false);
break;
case 2:
plane2.Draw(false);
break;
case 3:
cube.Draw(false);
break;
}
phong_shader.UnUse();
#ifdef SHOW_NORMALS
if (i == 0)
{
constant_shader.Use(model_matrix, view_matrix, projection_matrix);
constant_shader.SetMaterial(vec3(0.0f, 0.0f, 0.8f), specular, 128.0f, vec3(1.0f, 0.0f, 0.0f));
disc1.Draw(true);
constant_shader.UnUse();
}
#endif
}
model_matrix = mat4();
mat4 mz = model_matrix;
model_matrix = scale(model_matrix, vec3(0.5f, 0.5f, 16.0f));
phong_shader.Use(model_matrix, view_matrix, projection_matrix);
phong_shader.SetMaterial(vec3(0.0f, 0.0f, 0.8f), specular, 128.0f, ambient);
phong_shader.SetLightPosition(vec3(0.0f, 1000.0f, 0.0f));
cylinder1.Draw(false);
phong_shader.UnUse();
#ifdef SHOW_NORMALS
constant_shader.Use(model_matrix, view_matrix, projection_matrix);
constant_shader.SetMaterial(vec3(0.0f, 0.0f, 0.8f), specular, 128.0f, vec3(1.0f, 1.0f, 1.0f));
cylinder.Draw(true);
constant_shader.UnUse();
#endif
model_matrix = rotate(mz, radians(90.0f), y_axis);
model_matrix = scale(model_matrix, vec3(0.5f, 0.5f, 16.0f));
phong_shader.Use(model_matrix, view_matrix, projection_matrix);
phong_shader.SetMaterial(vec3(1.0f, 0.0f, 0.0f), specular, 128.0f, ambient);
phong_shader.SetLightPosition(vec3(0.0f, 1000.0f, 0.0f));
cylinder1.Draw(false);
phong_shader.UnUse();
model_matrix = rotate(mz, radians(-90.0f), vec3(1.0f, 0.0f, 0.0f));
model_matrix = scale(model_matrix, vec3(0.5f, 0.5f, 16.0f));
phong_shader.Use(model_matrix, view_matrix, projection_matrix);
phong_shader.SetMaterial(vec3(0.0f, 1.0f, 0.0f), specular, 128.0f, ambient);
phong_shader.SetLightPosition(vec3(0.0f, 1000.0f, 0.0f));
cylinder1.Draw(false);
phong_shader.UnUse();
cylinder1.UpdateValues(TestUpdate, window->LocalTime(), nullptr);
}