contains notes and images from:
Chapter 6 and 7 and 11 and 13 of Inventor Mentor
#include <Inventor/nodes/SoCone.h>
#include <Inventor/nodes/SoCube.h>
#include <Inventor/nodes/SoCylinder.h>
#include <Inventor/nodes/SoSphere.h>
SoCube * cub = new SoCube;
cub->width = 2;
cub->height= = 2;
cub->depth = 2;
SoCylinder * cyl = new SoCylinder;
cyl->height = 10;
cyl->radius = 2;
cyl->parts = SoCylinder::ALL; // ALL, SIDES, TOP, BOTTOM
SoSphere * sph = new SoSphere;
sph->radius = 4.5;
SoCone * con = new SoCone;
con->bottomRadius = 1.2
con->height = 4.0
con->parts = SoCone::ALL; // ALL, SIDES, BOTTOM
SoSphere * sph = new SoSphere;
Cone {
parts ALL
bottomRadius 1
height 2
}
Cube {
width 2
height 2
depth 2
}
Cylinder {
parts ALL
radius 1
height 2
}
Sphere {
radius 1
}
Textures
#include <Inventor/nodes/SoTexture2.h>
SoTexture2 * tex = new SoTexture2;
tex->filename.setValue("whatever.rgb");
tex->model = SoTexture2::MODULATE; // MODULATE, DECAL, BLEND
Texture2 {
filename "whatever.rgb"
model MODULATE
}
Files
#include <Inventor/nodes/SoFile.h>
SoSeparator * readFile(const char *filename)
{
char textBuffer[80];
//////////////////////
// Open the input file
///////////////////////
SoInput mySceneInput;
if (!mySceneInput.openFile(filename))
{
sprintf(textBuffer, "Cannot open file %s\n", filename);
showError(textBuffer);
return NULL;
}
////////////////////////////////////////
// Read the whole file into the database
////////////////////////////////////////
SoSeparator *myGraph = SoDB::readAll(&mySceneInput);
if (myGraph == NULL)
{
sprintf(textBuffer, "Problem reading file %s\n", filename);
showError(textBuffer);
return NULL;
}
mySceneInput.closeFile();
return myGraph;
}
File {
name "filename.iv"
}
Text
#include <Inventor/nodes/SoText2.h>
#include <Inventor/nodes/SoText3.h>
SoText2 * tex = new SoText2;
tex->string.setValue("whatever");
tex->spacing = 1;
tex->justification = SoText2::LEFT; // LEFT, CENTER, RIGHT
SoText3 * tex = new SoText3;
tex->string.setValue("whatever");
tex->spacing = 1;
tex->justification = SoText2::LEFT; // LEFT, CENTER, RIGHT
tex->part = SoText2::ALL; // FRONT, BACK, SIDES, ALL
Text2 {
string ""
spacing 1
justification LEFT
}
Text3 {
string ""
spacing 1
justification LEFT
parts ALL
}
Engines
#include <Inventor/nodes/SoRotor.h>
#include <Inventor/nodes/SoPendulum.h>
#include <Inventor/nodes/SoShuttle.h>
#include <Inventor/nodes/SoBlinker.h>
SoRotor * rot = new SoRotor;
SoPendulum * pen = new SoPendulum;
SoShuttle * shu = new SoShuttle;
SoBlinker * blin = new SoBlinker;
rot->rotation.setValue(SbVec3f(0, 1, 0), 3.14);
rot->speed = 4;
pen->rotation0.setValue(SbVec3f(0, 0, 1), 0.15);
pen->rotation1.setValue(SbVec3f(0, 0, -1), 0.15);
pen->speed = 0.04;
shu->translation0.setValue( -0.25, 0, 0);
shu->translation1.setValue(0.25, 0, 0);
shu->speed = 0.02;
blin->speed = 2; // 2 times per second
Shuttle {
translation 0.161366 0 0
translation0 -0.25 0 0
translation1 0.25 0 0
speed 0.02
}
Pendulum {
rotation 0 0 1 0.0108086
rotation0 0 0 1 0.15
rotation1 0 0 -1 0.15
speed 0.04
on TRUE
}
Rotor {
rotation 0 0 1 0
speed 1
on TRUE
}
Blinker {
whichChild -1
speed 1
on TRUE
}
The Beginning of the Rest of the Course - Videogames