本文整理汇总了C++中Viewer::addRenderable方法的典型用法代码示例。如果您正苦于以下问题:C++ Viewer::addRenderable方法的具体用法?C++ Viewer::addRenderable怎么用?C++ Viewer::addRenderable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Viewer
的用法示例。
在下文中一共展示了Viewer::addRenderable方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initialize_practical_05_scene
void initialize_practical_05_scene( Viewer& viewer )
{
//Set up a shader and add a 3D frame.
ShaderProgramPtr flatShader = std::make_shared<ShaderProgram>( "../../sfmlGraphicsPipeline/shaders/flatVertex.glsl",
"../../sfmlGraphicsPipeline/shaders/flatFragment.glsl");
viewer.addShaderProgram( flatShader );
FrameRenderablePtr frame = std::make_shared<FrameRenderable>(flatShader);
viewer.addRenderable(frame);
//Initialize a dynamic system (Solver, Time step, Restitution coefficient)
DynamicSystemPtr system = std::make_shared<DynamicSystem>();
EulerExplicitSolverPtr solver = std::make_shared<EulerExplicitSolver>();
system->setSolver(solver);
system->setDt(0.01);
//Create a renderable associated to the dynamic system
//This renderable is responsible for calling DynamicSystem::computeSimulationStep() in the animate() function
//It is also responsible for some of the key/mouse events
DynamicSystemRenderablePtr systemRenderable = std::make_shared<DynamicSystemRenderable>(system);
viewer.addRenderable(systemRenderable);
//Populate the dynamic system with particles, forcefields and create renderables associated to them for visualization.
//Uncomment only one of the following line
practical05_particles(viewer, system, systemRenderable);
//practical05_springs(viewer, system, systemRenderable);
//practical05_collisions(viewer, system, systemRenderable);
//practical05_playPool(viewer, system, systemRenderable);
//Finally activate animation
viewer.startAnimation();
}
示例2: initialize_practical_01_scene
void initialize_practical_01_scene(Viewer& viewer)
{
// create all shaders of this scene, then add them to the viewer
ShaderProgramPtr defaultShader
= std::make_shared<ShaderProgram>("../shaders/defaultVertex.glsl",
"../shaders/defaultFragment.glsl");
ShaderProgramPtr flatShader
= std::make_shared<ShaderProgram>("../shaders/flatVertex.glsl",
"../shaders/flatFragment.glsl");
viewer.addShaderProgram(defaultShader);
viewer.addShaderProgram(flatShader);
// create renderable objects
viewer.addRenderable(std::make_shared<FrameRenderable>(defaultShader));
std::shared_ptr<teachers::CubeRenderable> teachersCube
= std::make_shared<teachers::CubeRenderable>(flatShader);
teachersCube->setModelMatrix(glm::translate(glm::mat4(), glm::vec3(2.0, 0.0, 0.0)));
viewer.addRenderable(teachersCube);
std::shared_ptr<teachers::IndexedCubeRenderable> teachersIndexedCube
= std::make_shared<teachers::IndexedCubeRenderable>(flatShader);
teachersIndexedCube->setModelMatrix(glm::translate(glm::mat4(), glm::vec3(-2.0, 0.0, 0.0)));
viewer.addRenderable(teachersIndexedCube);
// MeshRenderablePtr mesh = std::make_shared<MeshRenderable>(pointLightShader, "./../meshes/suzanne.obj");
// mesh->setModelMatrix( glm::translate(glm::mat4(1.0), glm::vec3(-6,2,0)) );
// viewer.addRenderable(mesh);
}
示例3: main
int main(int argc, char** argv) {
// Read command lines arguments.
QApplication application(argc, argv);
// Instantiate the viewer.
Viewer viewer;
// build your scene here
//viewer.addRenderable(new Terrain(SIZE_TERRAIN));
//viewer.addRenderable(new Human(0.5));
Terrain * terrain = new Terrain(SIZE_TERRAIN);
viewer.addRenderable(terrain);
viewer.addRenderable(new Landscape());
Human * human = new Human(1.0,Vec(0.0,0.0,30.0),Vec(0.0,0.0,HEIGHT_SCENE));
viewer.addRenderable(new DynamicSystem(terrain,human));
viewer.setWindowTitle("Projet Graphique 3D");
// Make the viewer window visible on screen.
viewer.show();
// Run main loop.
return application.exec();
}
示例4: main
int main(int argc, char** argv)
{
// Read command lines arguments.
QApplication application(argc,argv);
// Instantiate the viewer.
Viewer viewer;
// build your scene here
//viewer.addRenderable(new Cube());
//viewer.addRenderable(new Cylinder());
//viewer.addRenderable(new Model());
//Dragon *d = new Dragon();
viewer.addRenderable(new Dragon());
viewer.setWindowTitle("viewer");
// Make the viewer window visible on screen.
viewer.show();
// Run main loop.
return application.exec();
}
示例5: main
int main(int argc, char** argv) {
// Read command lines arguments.
QApplication application(argc, argv);
srand(time(NULL));
float x, y, z;
int i, j;
// Instantiate the viewer.
Viewer viewer;
// build your scene here
// add sea floor
viewer.addRenderable(new seaFloor());
//viewer.addRenderable(new LightsMaterials());
// #1 Group of FishB
x = 0;
y = 0;
z = 0;
for (i = 0; i < 4; i++)
for (j = 0; j < 4; j++)
viewer.addRenderable(new fishB(x + (i * 1.2), y + j, z,
0.1, 0, 0,
0.8, 0.2, 0.2));
// #2 Group of FishB
x = -5;
y = -1;
z = 17;
for (i = 0; i < 3; i++)
for (j = 0; j < 5; j++)
viewer.addRenderable(new fishB(x - (3.2 * 0.05 * i / 0.17), y + j + (3.2 * 0.07 * i / 0.17), z - (3.2 * 0.05 * i / 0.17),
-0.05, 0.07, -0.05,
0.2, 0.8, 0.2));
// #3 Some Crabs
viewer.addRenderable(new crab(0, 0, 0.04, 0.02));
viewer.addRenderable(new crab(0, +15, 0.01, 0.04));
viewer.addRenderable(new crab(0, +20, 0.02, 0.01));
viewer.addRenderable(new crab(-5, 2, -0.03, 0.01));
viewer.addRenderable(new crab(-10, -4, +0.02, -0.04));
viewer.addRenderable(new crab(15, 2, +0.07, 0.01));
// #4 Group of FishB
x = -5;
y = 1;
z = 1;
for (i = 0; i < 3; i++)
for (j = 0; j < 2; j++)
viewer.addRenderable(new fishB(x + (i * (1.3)), y + j, z,
0.3, 0.05, 0.01,
-0.8, 0.2, 0.2));
// #5 Group of FishB
x = -10;
y = -12;
z = -3;
for (i = 0; i < 4; i++)
for (j = 0; j < 4; j++)
viewer.addRenderable(new fishB(x + (i * (1.2)), y + j, z,
0.1, 0, 0,
0.8, 0.2, 0.2));
// #6 Different Fish
viewer.addRenderable(new fishA(0, 0, 15,
-0.07, 0.00, -0.05,
1, 0, 0));
viewer.addRenderable(new fishA(0, 1, 25,
-0.09, 0.00, -0.05,
0.1, 0.6, 0.3));
viewer.addRenderable(new fishA(6, -2, 0,
0.01, +0.01, -0.05,
0.3, 0.2, 0.7));
viewer.addRenderable(new fishA(-16,+4, -5,
-0.01,0.00, +0.1,
1,1,1));
viewer.addRenderable(new fishA(-25,-1,-7,
0.0 ,0.04, +0.08,
1,1,0));
// #7 Diver and Bubbles : added inside viewer, following lines are for debug only
//viewer.addRenderable(new Diver(5));
//viewer.addRenderable(new Bubble(0, 0, 20, 0.5, 0.1));
// #8 Pacman
// added in the viewer, after some time has passed
//.........这里部分代码省略.........