本文整理汇总了C++中ObjectGroup::add方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectGroup::add方法的具体用法?C++ ObjectGroup::add怎么用?C++ ObjectGroup::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectGroup
的用法示例。
在下文中一共展示了ObjectGroup::add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
/* world->add( new Sphere(Vector(0, 0, -1), */
/* 0.5, */
/* new Lambertian( */
/* new ImageTexture("earth.bmp")))); */
/* world->add( new Triangle(Vector(0.2f, 0.5f, -1), Vector(0, 1.5f, -1), Vector(0, 0.5f, -2), new Metal(new ConstantTexture(0.8f, 0.8f, 0.8f), 0.0f)) ); */
/* world->add( new Sphere(Vector(-0.5, 0, -2.2), 0.5, new Metal(new ConstantTexture(0.9, 0.9, 0.9), 0)) ); */
/* world->add( new Sphere(Vector(-1, 0, -1), 0.5, new Dielectric(1.5f)) ); */
/* world->add( new Sphere(Vector(-1, 0, -1), 0.45, new Dielectric(1.f, 1.5f)) ); */
/* world->add( new Sphere(Vector(-2, 0, -1), 0.5, new Light(new ConstantTexture(20.f, 20.f, 20.f))) ); */
/* world->add( new Sphere(Vector(0, 2, -1.5), 0.5, new Light(new ConstantTexture(20.f, 20.f, 20.f))) ); */
// cornell box
//
// /B---C
// A---D/|
// | F-|-G
// E/--H/
Vector A = Vector(-1, 1, -1);
Vector B = Vector(-1, 1, 1);
Vector C = Vector(1, 1, 1);
Vector D = Vector(1, 1, -1);
Vector E = Vector(-1, -1, -1);
Vector F = Vector(-1, -1, 1);
Vector G = Vector(1, -1, 1);
Vector H = Vector(1, -1, -1);
// back
Material* backMat = new Lambertian(new ConstantTexture(1.f, 1.f, 1.f));
world->add( new Triangle(F, B, G, backMat));
world->add( new Triangle(C, G, B, backMat));
// front - letting ray in from the camera
// /!\ not part of the original cornell box
/* Material* frontMat = new Lambertian(new ConstantTexture(1.f, 1.f, 1.f)); */
/* world->add( new Triangle(E, H, A, frontMat)); */
/* world->add( new Triangle(D, A, H, frontMat)); */
// floor
Material* floorkMat = new Lambertian(new ConstantTexture(1.f, 1.f, 1.f));
world->add( new Triangle(E, F, G, floorkMat));
world->add( new Triangle(G, H, E, floorkMat));
// ceiling
Material* ceilingMat = new Lambertian(new ConstantTexture(1.f, 1.f, 1.f));
/* Material* ceilingMat = new Metal(new ConstantTexture(1.f, 1.f, 1.f), 0); */
world->add( new Triangle(A, C, B, ceilingMat));
world->add( new Triangle(C, A, D, ceilingMat));
// left
Material* leftMat = new Lambertian(new ConstantTexture(1.f, 0.f, 0.f));
world->add( new Triangle(A, B, E, leftMat));
world->add( new Triangle(B, F, E, leftMat));
// right
Material* rightMat = new Lambertian(new ConstantTexture(0.f, 1.f, 0.f));
world->add( new Triangle(D, H, C, rightMat));
world->add( new Triangle(C, H, G, rightMat));
// light
float lightIntensity = 10.f;
float lightSize = 0.3f;
示例2: init
/**
* Init the scene and OpenGL state
*
*/
void MyScene::init()
{
_objects[CUBE].load("./data/cube.off");
_objects[PYRAMID].load("./data/pyramid.off");
_objects[DISK].load("./data/disk.off");
_objects[DISKHOLE].load("./data/diskhole.off");
_objects[CYLINDER].load("./data/cylinder.off");
_objects[CONE].load("./data/cone.off");
_objects[SPHERE].load("./data/sphere.off");
_objects[AIRCRAFT].load("./data/aircraft.off");
_objects[VENUS].load("./data/venus.off");
_objects[NEFERTITI].load("./data/nefertiti.off");
Mesh* cone = new Mesh();
cone->load("./data/cone.off");
cone->addTransformation(glTranslatef,0.0,0.0,_radius);
cone->addTransformation(glScalef,0.1, 0.1, 0.5);
Mesh* cylinder = new Mesh();
cylinder->load("./data/cylinder.off");
cylinder->addTransformation(glScalef,0.01, 0.01, 1.0);
ObjectGroup* zArrow = new ObjectGroup();
zArrow->add(cone);
zArrow->add(cylinder);
//zArrow->addTransformation(glScalef, _radius/2, _radius/2, _radius/2);
zArrow->addTransformation(glColor3f, 0, 0, 0.5);
ObjectGroup* xArrow = zArrow->clone();
xArrow->addTransformation(glRotatef, 90, 0, 1, 0);
xArrow->addTransformation(glColor3f, 0.5, 0, 0);
ObjectGroup* yArrow = zArrow->clone();
yArrow->addTransformation(glRotatef, -90, 1, 0, 0);
yArrow->addTransformation(glColor3f, 0, 0.5, 0);
Mesh* centerSphere = new Mesh();
centerSphere->load("./data/sphere.off");
centerSphere->addTransformation(glScalef,0.05, 0.05, 0.05);
centerSphere->addTransformation(glColor3f, 0.5, 0.5, 0.5);
_allObjects = new ObjectGroup();
_allObjects->add(centerSphere);
_allObjects->add(xArrow);
_allObjects->add(yArrow);
_allObjects->add(zArrow);
Mesh* sun = new Mesh();
sun->load("./data/sphere.off");
sun->addTransformation(glScalef, 0.3, 0.3, 0.3);
sun->addTransformation(glColor3f, 0.9, 0.2, 0.0);
_allObjects->add(sun);
ObjectGroup* earthAndMoon = new ObjectGroup();
_earthAndMoonRotator = new ParametrizedRotator(0,0,1);
earthAndMoon->addTransformation(_earthAndMoonRotator);
earthAndMoon->addTransformation(glTranslatef, 2, 0.0, 0.0);
Mesh* earth = new Mesh();
earth->load("./data/sphere.off");
earth->addTransformation(glScalef, 0.1, 0.1, 0.1);
earth->addTransformation(glColor3f, 0.0, 0.2, 0.9);
earthAndMoon->add(earth);
Mesh* moon = new Mesh();
moon->load("./data/sphere.off");
_moonRotator = new ParametrizedRotator(0,0,1);
moon->addTransformation(_moonRotator);
moon->addTransformation(glTranslatef, 0.5, 0.0, 0.0);
moon->addTransformation(glScalef, 0.04, 0.04, 0.04);
moon->addTransformation(glColor3f, 0.3, 0.3, 0.3);
earthAndMoon->add(moon);
_allObjects->add(earthAndMoon);
setDayOfYear(0);
// set antialiased lines
//glEnable(GL_LINE_SMOOTH); // FIXME current MESA driver messes up with antialiasing ...
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
glLineWidth(1.5);
}