Text archives Help
- From: boulos@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r326 - trunk/scenes
- Date: Mon, 16 May 2005 15:56:40 -0600 (MDT)
Author: boulos
Date: Mon May 16 15:56:40 2005
New Revision: 326
Modified:
trunk/scenes/primtest.cc
Log:
Fixing invalid printf command (std::string should
not be passed as %s parameter)
Modified: trunk/scenes/primtest.cc
==============================================================================
--- trunk/scenes/primtest.cc (original)
+++ trunk/scenes/primtest.cc Mon May 16 15:56:40 2005
@@ -64,31 +64,31 @@
string arg = args[i];
if(arg == "-scale"){
if(!getDoubleArg(i, args, scale))
- throw IllegalArgument("scene primtest -scale", i, args);
+ throw IllegalArgument("scene primtest -scale", i, args);
} else if(arg == "-texscale"){
if(!getDoubleArg(i, args, texscale))
- throw IllegalArgument("scene primtest -texscale", i, args);
+ throw IllegalArgument("scene primtest -texscale", i, args);
} else if(arg == "-num"){
if(!getResolutionArg(i, args, numx, numy))
- throw IllegalArgument("scene primtest -num", i, args);
+ throw IllegalArgument("scene primtest -num", i, args);
} else if(arg == "-material"){
if(!getStringArg(i, args, material))
- throw IllegalArgument("scene primtest -material", i, args);
+ throw IllegalArgument("scene primtest -material", i, args);
} else if(arg == "-array"){
if(!getStringArg(i, args, arraytype))
- throw IllegalArgument("scene primtest -array", i, args);
+ throw IllegalArgument("scene primtest -array", i, args);
} else if(arg == "-model"){
if(!getStringArg(i, args, modelName))
- throw IllegalArgument("scene primtest -model", i, args);
+ throw IllegalArgument("scene primtest -model", i, args);
} else {
if(arg[0] == '-' || set_primtype) {
- cerr << "Valid options for scene primtest:\n";
- cerr << " -scale - sets size of primitives\n";
- cerr << " -num MxN - sets array of primitives to M by N\n";
- throw IllegalArgument("scene primtest", i, args);
+ cerr << "Valid options for scene primtest:\n";
+ cerr << " -scale - sets size of primitives\n";
+ cerr << " -num MxN - sets array of primitives to M by N\n";
+ throw IllegalArgument("scene primtest", i, args);
} else {
- primtype = arg;
- set_primtype = true;
+ primtype = arg;
+ set_primtype = true;
}
}
}
@@ -106,35 +106,35 @@
matl = new MetalMaterial(Color(RGB(0.7f,0.7f,0.8f)));
else if(material == "checker")
matl = new Phong(new CheckerTexture<Color>(Color(RGB(.6,.6,.6)),
- Color(RGB(.6,0,0)),
- Vector(1,0,0)*texscale,
- Vector(0,1,0)*texscale),
- new Constant<Color>(Color(RGB(.6,.6,.6))),
- 32,
- new Constant<double>(0));
+ Color(RGB(.6,0,0)),
+ Vector(1,0,0)*texscale,
+ Vector(0,1,0)*texscale),
+ new Constant<Color>(Color(RGB(.6,.6,.6))),
+ 32,
+ new Constant<double>(0));
else if(material == "checker2")
matl = new Phong(new CheckerTexture<Color>(Color(RGB(.6,.6,.6)),
- Color(RGB(.6,0,0)),
- Vector(1,0,0)*texscale,
- Vector(0,1,0)*texscale),
- new Constant<Color>(Color(RGB(.6,.6,.6))),
- 32,
- new CheckerTexture<double>(0.2, 0.5,
- Vector(1,0,0)*texscale,
- Vector(0,1,0)*texscale));
+ Color(RGB(.6,0,0)),
+ Vector(1,0,0)*texscale,
+ Vector(0,1,0)*texscale),
+ new Constant<Color>(Color(RGB(.6,.6,.6))),
+ 32,
+ new CheckerTexture<double>(0.2, 0.5,
+ Vector(1,0,0)*texscale,
+ Vector(0,1,0)*texscale));
else if(material == "checker3")
matl = new Checker(new Phong(Color(RGB(.6,.6,.6)), Color(RGB(.6,.6,.6)),
32, 0.2),
- new Phong(Color(RGB(.6,0,0)), Color(RGB(.6,.6,.6)),
32, 0.5),
- Vector(1,0,0)*texscale, Vector(0,1,0)*texscale);
+ new Phong(Color(RGB(.6,0,0)), Color(RGB(.6,.6,.6)),
32, 0.5),
+ Vector(1,0,0)*texscale, Vector(0,1,0)*texscale);
else if(material == "marble")
{
matl = new Phong(
new MarbleTexture<Color>(
Color(RGB(0.1,0.2,0.5)), Color(RGB(0.7,0.8,1.0)),
10.0, 1.0, 15.0, 6, 2.0, 0.6 ),
- new Constant<Color>(Color(RGB(.6,.6,.6))),
- 32,
- new Constant<double>(0));
+ new Constant<Color>(Color(RGB(.6,.6,.6))),
+ 32,
+ new Constant<double>(0));
mapr = new UniformMapper();
}
else if(material == "wood")
@@ -160,15 +160,15 @@
if(primtype == "simplesphere"){
for(int i=0;i<numx;i++){
for(int j=0;j<numy;j++){
- int idx = j*numx+i;
- double radius = (idx+1)/static_cast<double>(numx*numy)*scale/max;
- Point p((i/static_cast<double>(numx-1) - 0.5)*scale*2,
- (j/static_cast<double>(numy-1) - 0.5)*scale*2,
- 0);
+ int idx = j*numx+i;
+ double radius = (idx+1)/static_cast<double>(numx*numy)*scale/max;
+ Point p((i/static_cast<double>(numx-1) - 0.5)*scale*2,
+ (j/static_cast<double>(numy-1) - 0.5)*scale*2,
+ 0);
Primitive* prim = new Sphere( matl, p, radius );
if ( mapr )
prim->setTexCoordMapper( mapr );
- group->add( prim );
+ group->add( prim );
}
}
} else if (primtype == "simplesuperellipsoid"){
@@ -191,13 +191,13 @@
Vector p2(scale/max, scale/max, scale/max);
for(int i=0;i<numx;i++){
for(int j=0;j<numy;j++){
- Point p((i/static_cast<double>(numx-1) - 0.5)*scale*2,
- (j/static_cast<double>(numy-1) - 0.5)*scale*2,
- 0);
+ Point p((i/static_cast<double>(numx-1) - 0.5)*scale*2,
+ (j/static_cast<double>(numy-1) - 0.5)*scale*2,
+ 0);
Primitive* prim = new Cube( matl, p-p2, p2.x()*1.156, p2.y()*1.156,
p2.z()*1.156 );
if ( mapr )
prim->setTexCoordMapper( mapr );
- group->add( prim );
+ group->add( prim );
}
}
} else if(primtype == "sphere"){
@@ -225,9 +225,9 @@
Primitive* o2 = new Sphere(matl, Point(0,0,0), scale/max);
double s = scale/max/1.414*2*(1+1.e-10);
LinearMapper* map = new LinearMapper(Point(0,0,0),
- Vector(s,0,0),
- Vector(0,s,0),
- Vector(0,0,s));
+ Vector(s,0,0),
+ Vector(0,s,0),
+ Vector(0,0,s));
o1->setTexCoordMapper( mapr ? mapr : map );
o2->setTexCoordMapper( mapr ? mapr : map );
spinprim = new Difference(o1, o2);
@@ -246,7 +246,7 @@
t.initWithScale(Vector(scale/max*30, scale/max*30, scale/max*30));
Group *model = new Group();
if (!readPlyFile(modelName, t, model, 0, matl))
- printf("error loading or reading ply file: %s\n", modelName);
//would be better to throw an error.
+ printf("error loading or reading ply file: %s\n",
modelName.c_str()); //would be better to throw an error.
group->add(model);
} else if (primtype == "heightfield") {
Primitive* prim = new Heightfield(matl, "../sinc200x200.hf", Point(-0.2,
-0.2, 0.2), Point(0.2, 0.2, 0.4));
@@ -260,88 +260,88 @@
if(spinprim){
if(arraytype == "spin"){
for(int i=0;i<numx;i++){
- for(int j=0;j<numy;j++){
- Vector p((i/static_cast<double>(numx-1) - 0.5)*scale*2,
- (j/static_cast<double>(numy-1) - 0.5)*scale*2,
- 0);
- double a1 = i/static_cast<double>(numx-1)*M_PI*2;
- double a2 = j/static_cast<double>(numy-1)*M_PI*2;
- AffineTransform t;
+ for(int j=0;j<numy;j++){
+ Vector p((i/static_cast<double>(numx-1) - 0.5)*scale*2,
+ (j/static_cast<double>(numy-1) - 0.5)*scale*2,
+ 0);
+ double a1 = i/static_cast<double>(numx-1)*M_PI*2;
+ double a2 = j/static_cast<double>(numy-1)*M_PI*2;
+ AffineTransform t;
t.initWithIdentity();
- t.rotate(Vector(0,1,0), a1);
- t.rotate(Vector(1,0,0), a2);
- t.translate(p);
- group->add(new InstanceRT(spinprim, t));
- }
+ t.rotate(Vector(0,1,0), a1);
+ t.rotate(Vector(1,0,0), a2);
+ t.translate(p);
+ group->add(new InstanceRT(spinprim, t));
+ }
}
} else if(arraytype == "shift"){
for(int i=0;i<numx;i++){
- for(int j=0;j<numy;j++){
- Vector p((i/static_cast<double>(numx-1) - 0.5)*scale*2,
- (j/static_cast<double>(numy-1) - 0.5)*scale*2,
- 0);
- group->add(new InstanceT(spinprim, p));
- }
+ for(int j=0;j<numy;j++){
+ Vector p((i/static_cast<double>(numx-1) - 0.5)*scale*2,
+ (j/static_cast<double>(numy-1) - 0.5)*scale*2,
+ 0);
+ group->add(new InstanceT(spinprim, p));
+ }
}
} else if(arraytype == "scale"){
for(int i=0;i<numx;i++){
- for(int j=0;j<numy;j++){
- Vector p((i/static_cast<double>(numx-1) - 0.5)*scale*2,
- (j/static_cast<double>(numy-1) - 0.5)*scale*2,
- 0);
- int idx = j*numx+i;
- double scale = (idx+1)/static_cast<double>(numx*numy);
- group->add(new InstanceST(spinprim, Vector(scale, scale, scale),
p));
- }
+ for(int j=0;j<numy;j++){
+ Vector p((i/static_cast<double>(numx-1) - 0.5)*scale*2,
+ (j/static_cast<double>(numy-1) - 0.5)*scale*2,
+ 0);
+ int idx = j*numx+i;
+ double scale = (idx+1)/static_cast<double>(numx*numy);
+ group->add(new InstanceST(spinprim, Vector(scale, scale, scale),
p));
+ }
}
} else if(arraytype == "nuscale"){
for(int i=0;i<numx;i++){
- for(int j=0;j<numy;j++){
- Vector p((i/static_cast<double>(numx-1) - 0.5)*scale*2,
- (j/static_cast<double>(numy-1) - 0.5)*scale*2,
- 0);
- double xscale = (i+1)/static_cast<double>(numx);
- double yscale = (j+1)/static_cast<double>(numy);
- group->add(new InstanceST(spinprim, Vector(xscale, yscale, 1), p));
- }
+ for(int j=0;j<numy;j++){
+ Vector p((i/static_cast<double>(numx-1) - 0.5)*scale*2,
+ (j/static_cast<double>(numy-1) - 0.5)*scale*2,
+ 0);
+ double xscale = (i+1)/static_cast<double>(numx);
+ double yscale = (j+1)/static_cast<double>(numy);
+ group->add(new InstanceST(spinprim, Vector(xscale, yscale, 1), p));
+ }
}
} else if(arraytype == "spinscale"){
for(int i=0;i<numx;i++){
- for(int j=0;j<numy;j++){
- Vector p((i/static_cast<double>(numx-1) - 0.5)*scale*2,
- (j/static_cast<double>(numy-1) - 0.5)*scale*2,
- 0);
- double a1 = i/static_cast<double>(numx-1)*M_PI*2;
- double a2 = j/static_cast<double>(numy-1)*M_PI*2;
- int idx = j*numx+i;
- double scale = (idx+1)/static_cast<double>(numx*numy);
- AffineTransform t;
+ for(int j=0;j<numy;j++){
+ Vector p((i/static_cast<double>(numx-1) - 0.5)*scale*2,
+ (j/static_cast<double>(numy-1) - 0.5)*scale*2,
+ 0);
+ double a1 = i/static_cast<double>(numx-1)*M_PI*2;
+ double a2 = j/static_cast<double>(numy-1)*M_PI*2;
+ int idx = j*numx+i;
+ double scale = (idx+1)/static_cast<double>(numx*numy);
+ AffineTransform t;
t.initWithIdentity();
- t.scale(Vector(scale, scale, scale));
- t.rotate(Vector(0,1,0), a1);
- t.rotate(Vector(1,0,0), a2);
- t.translate(p);
- group->add(new InstanceRST(spinprim, t));
- }
+ t.scale(Vector(scale, scale, scale));
+ t.rotate(Vector(0,1,0), a1);
+ t.rotate(Vector(1,0,0), a2);
+ t.translate(p);
+ group->add(new InstanceRST(spinprim, t));
+ }
}
} else if(arraytype == "spinscale2"){
for(int i=0;i<numx;i++){
- for(int j=0;j<numy;j++){
- Vector p((i/static_cast<double>(numx-1) - 0.5)*scale*2,
- (j/static_cast<double>(numy-1) - 0.5)*scale*2,
- 0);
- double a1 = i/static_cast<double>(numx-1)*M_PI*2;
- double a2 = j/static_cast<double>(numy-1)*M_PI*2;
- int idx = j*numx+i;
- double scale = (idx+1)/static_cast<double>(numx*numy);
- AffineTransform t;
+ for(int j=0;j<numy;j++){
+ Vector p((i/static_cast<double>(numx-1) - 0.5)*scale*2,
+ (j/static_cast<double>(numy-1) - 0.5)*scale*2,
+ 0);
+ double a1 = i/static_cast<double>(numx-1)*M_PI*2;
+ double a2 = j/static_cast<double>(numy-1)*M_PI*2;
+ int idx = j*numx+i;
+ double scale = (idx+1)/static_cast<double>(numx*numy);
+ AffineTransform t;
t.initWithIdentity();
- t.scale(Vector(scale, scale, scale));
- t.rotate(Vector(0,1,0), a1);
- t.rotate(Vector(1,0,0), a2);
- t.translate(p);
- group->add(new Instance(spinprim, t));
- }
+ t.scale(Vector(scale, scale, scale));
+ t.rotate(Vector(0,1,0), a1);
+ t.rotate(Vector(1,0,0), a2);
+ t.translate(p);
+ group->add(new Instance(spinprim, t));
+ }
}
} else {
throw IllegalArgument("Unknown array type for primtest: "+primtype, 0,
args);
@@ -349,17 +349,17 @@
}
if(bgpoly){
Material* bgmatl = new Lambertian(new
CheckerTexture<Color>(Color(RGB(0.4, 0.4, 0.4)),
-
Color(RGB(0.2, 0.2, 0.2)),
-
Vector(1,0,0)*numx*2,
-
Vector(0,1,0)*numy*2));
+
Color(RGB(0.2, 0.2, 0.2)),
+
Vector(1,0,0)*numx*2,
+
Vector(0,1,0)*numy*2));
group->add(new Parallelogram(bgmatl, Point(-scale-1./max, -scale-1./max,
-1.5/max),
- Vector(scale*2+2./max, 0, 0), Vector(0,
scale*2+2./max, 0)));
+ Vector(scale*2+2./max, 0, 0), Vector(0,
scale*2+2./max, 0)));
}
Scene* scene = new Scene();
scene->setBackground(new LinearBackground(Color(RGB(0.2, 0.4, 0.9)),
- Color(RGB(0.0,0.0,0.0)),
- Vector(0,1,0)));
+ Color(RGB(0.0,0.0,0.0)),
+ Vector(0,1,0)));
scene->setObject(group);
LightSet* lights = new LightSet();
- [MANTA] r326 - trunk/scenes, boulos, 05/16/2005
Archive powered by MHonArc 2.6.16.