本文整理汇总了C++中Sphere::create方法的典型用法代码示例。如果您正苦于以下问题:C++ Sphere::create方法的具体用法?C++ Sphere::create怎么用?C++ Sphere::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sphere
的用法示例。
在下文中一共展示了Sphere::create方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateTestScene
void Scene::CreateTestScene()
{
Material* lambert1 = new LambertMaterial(glm::vec3(1, 0, 0));
Material* lambert2 = new LambertMaterial(glm::vec3(0, 1, 0));
Cube* c = new Cube();
c->material = lambert1;
c->transform = Transform(glm::vec3(1,0,0), glm::vec3(40,20,45), glm::vec3(1,1,1));
c->create();
c->setBBox();
this->objects.append(c);
Sphere* s = new Sphere();
s->material = lambert2;
s->transform = Transform(glm::vec3(-1,0,0), glm::vec3(30,50,30), glm::vec3(1,2,1));
s->create();
s->setBBox();
this->objects.append(s);
unsigned int w = 400, h = 400;
camera = Camera(w, h);
camera.near_clip = 0.1f;
camera.far_clip = 100.0f;
camera.create();
film = Film(w, h);
}
示例2: main
int main(int argc, char** argv) {
Engine* engine = new Engine();
if(!engine->init()) {
std::cout << "Engine initialization failed\n";
return 1;
}
engine->getShaderManager()->createProgram("mainShader", "Shaders/VertexShader.glsl", "Shaders/FragmentShader.glsl");
GLuint program = engine->getShaderManager()->getProgram("mainShader");
if(program == 0) {
std::cout << "Program initialization failed\n";
return 2;
}
engine->getSceneManager()->setProgram(program);
Skybox* skybox = new Skybox();
skybox->create(40.0f);
skybox->setRotation(glm::vec3(0.0f, 180.0f, 0.0f));
skybox->addMaterial(0, "Resources/Copyrighted/skybox1.png", 1.0f, 0.0f, 0.0f, 0.0f, engine->getTextureLoader());
engine->getModelManager()->setModel("skybox", skybox);
Cuboid* floorBox = new Cuboid();
floorBox->create(40.0f, 1.0f, 40.0f, glm::vec4(0.24f, 0.267f, 0.337f, 1.0f));
floorBox->setPosition(glm::vec3(0.0f, -8.0f, 0.0f));
engine->getModelManager()->setModel("floorBox", floorBox);
glm::vec3 sunPosition(-8.7f, 20.0f, 11.1f);
engine->getSceneManager()->addLight(0, sunPosition, glm::vec3(1.0), 1.0f, 0.0, 0.0);
Sphere* sun = new Sphere();
sun->create(1.2f, 16, 16, glm::vec4(1.0f, 1.0f, 0.9f, 1.0f));
sun->setBaseMaterial(1.0f, 0.0f, 0.0f, 0.0f);
sun->setPosition(sunPosition);
engine->getModelManager()->setModel("sun", sun);
glm::vec3 lampPosition(8.0f, -1.0f, 5.0f);
engine->getSceneManager()->addLight(1, lampPosition, glm::vec3(4.0f, 1.0f, 1.0f), 1.0f, 0.003f, 0.0005f);
Sphere* lamp = new Sphere();
lamp->create(0.3f, 16, 16, glm::vec4(1.0f, 0.2f, 0.2f, 1.0f));
lamp->setBaseMaterial(1.0f, 0.0f, 0.0f, 0.0f);
lamp->setPosition(lampPosition);
engine->getModelManager()->setModel("lamp", lamp);
Eel* eel = new Eel();
eel->create(10.0f, 0.5f, 16);
eel->setPosition(glm::vec3(0.0f, 0.0f, 0.0f));
eel->addMaterial(0, "Resources/Copyrighted/scales1_2.png", 0.05f, 0.6f, 3.5f, 12.0f, engine->getTextureLoader());
eel->addMaterial(1, "Resources/Textures/sphere_dots.png", 0.25f, 0.4f, 0.7f, 1.0f, engine->getTextureLoader());
eel->addNormalMap("Resources/Copyrighted/scales1-normal3.png", engine->getTextureLoader());
engine->getModelManager()->setModel("eel", eel);
Sphere* sphere = new Sphere();
sphere->create(1.0f, 24, 48);
sphere->setPosition(glm::vec3(0.0f, -2.0f, 14.0f));
sphere->setRotation(glm::vec3(30.0f, 0.0f, 0.0f));
sphere->setRotationSpeed(glm::vec3(0.0f, 20.0f, 0.0f));
sphere->addMaterial(0, "Resources/Textures/sphere1.bmp", 0.02f, 0.3f, 2.5f, 15.0f, engine->getTextureLoader());
sphere->addMaterial(1, "Resources/Textures/sphere_dots.png", 0.02f, 0.8f, 1.0f, 1.0f, engine->getTextureLoader());
sphere->addNormalMap("Resources/Copyrighted/fish-normal.bmp", engine->getTextureLoader());
engine->getModelManager()->setModel("sphere", sphere);
engine->run();
delete engine;
return 0;
}
示例3: OnCreate
void OnCreate() {
// important: call base class to load extensions
GLWindowEx::OnCreate();
// does this driver support multitexture?
_bHaveMultitex = glex::Supports( "GL_ARB_multitexture" );
if (!_bHaveMultitex) {
// warn the user if multitexture not supported
App::MsgPrintf("GL_ARB_multitexture NOT found");
}
// if it supports multitexture, turn it on
_bMultitex = _bHaveMultitex;
// clear window first: it might take a moment before image loads
glClear(GL_COLOR_BUFFER_BIT);
SwapBuffers();
// load image
_images[0].Load("left.bmp");
_images[1].Load("right.bmp");
_images[2].Load("top.bmp");
_images[3].Load("bottom.bmp");
_images[4].Load("front.bmp");
_images[5].Load("back.bmp");
_images[6].Load("checker3.bmp");
_images[7].Load("star.bmp");
glGenTextures(8, &_textures[0]);
// build 2D mip-maps from image
for (int i = 0; i<7;i++) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glBindTexture(GL_TEXTURE_2D, _textures[i]);
_images[i].gluBuild2DMipmaps();
_images[i].Free();
};
// last star texture
glBindTexture(GL_TEXTURE_2D, _textures[7]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
_images[7].gluBuild2DMipmaps();
_images[7].Free();
// set the projection required
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-1.0f, +1.0f, -1.0f, +1.0f, 1.0f, +30.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glViewport(0,0, Width(), Height());
glEnable(GL_DEPTH_TEST);
// set the background clear colour to black
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
// set the shade model to smooth (Gouraud shading)
glShadeModel(GL_SMOOTH);
// remove back faces
glEnable(GL_CULL_FACE);
_material1.create(Color::black(), Color(0.9f,0.9f,0.9f,1.0f));
_material2.create(Color::black(), Color(0.7f,0.7f,0.7f,0.5f));
_material3.create(Color::black(), Color::black(), Color::yellow());
// setup some lights (ambient is turned off on all lights)
_light1.create(0, Color::black(), Color(0.5f,0.5f,0.5f,1.0f));
_light2.create(1, Color::black(), Color(0.5f,0.5f,0.5f,1.0f));
_light3.create(2, Color::black(), Color(0.5f,0.5f,0.0f,1.0f));
_light4.create(3, Color::black(), Color(0.5f,0.5f,0.5f,1.0f));
_light5.create(4, Color::black(), Color(0.5f,0.5f,0.5f,1.0f));
// turn the global ambient off by setting it to zero
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, Color::black().rgba());
_light3.setPosition(Vector4f(0.0,5.0,-3.0,1.0));
// Turn on the lights
_light1.apply();
_light2.apply();
_light3.apply();
_light4.apply();
_light5.apply();
// setup the two spheres
_sphere1.create(0.1f, 10, 10, false);
_sphere2.create(1.0f, 20, 20, true);
_cameraAngle = 15.0;
_cameraPosition = -5.0;
_cameraRotation = 0.0;
_fullscreen = false;
//.........这里部分代码省略.........