Transformation


SoScale

SoScale changes the size of the shapes.

Graphics



include file #include <Inventor/nodes/SoScale.h>
declaration SoScale *myScale = new SoScale
SoScale *yourScale = new SoScale
SoScale *herScale = new SoScale
field(attribute) myScale -> scaleFactor.setValue(1,5,1);
yourScale -> scaleFactor.setValue(7,0.4,4);
herScale -> scaleFactor.setValue(0.2,0.4,6);

"scaleFactor.setValue(x,y,z);" decides scale magnification along x, y, and z axis.
use: hasira ->addChild(myScale); hasira ->addChild(myColor); hasira->addChild(new SoCylinder); root ->addChild(hasira); maru ->addChild(yourScale); maru ->addChild(yourColor); maru ->addChild(new SoSphere); root ->addChild(maru); sankaku -> addChild(herScale); sankaku -> addChild(herColor); sankaku ->addChild(new SoCone); root -> addChild(sankaku);

c++ code



SoTranslation

SoTranslation move the objects.

Graphics



include file #include <Inventor/nodes/SoTranslation.h>
declaration SoTranslation *yourMove = new SoTranslation;
SoTranslation *herMove = new SoTranslation;
field(attribute)yourMove -> translation.setValue(0.0,-1.0,0.0);
herMove -> translation.setValue(0.0,2.3,0.0);

In "translation.setValue(x,y,z)", The position is decided.
use: hasira ->addChild(myColor); hasira->addChild(new SoCylinder); root ->addChild(hasira); maru ->addChild(yourMove); maru ->addChild(yourColor); maru ->addChild(new SoSphere); root ->addChild(maru); sankaku ->addChild(herMove); sankaku -> addChild(herColor); sankaku ->addChild(new SoCone); root -> addChild(sankaku);

C++ code



SoTransform

SoTransform includes all the other effects in Sotransformation; it changes position, angle, scale at the same time.

Graphics



include file #include <Inventor/nodes/SoTransform.h>
declarationSoTransform *move1 = new SoTransform;
SoTransform *move2 = new SoTransform;
SoTransform *move3 = new SoTransform;
field(attribute)move1 -> scaleFactor.setValue(3.0, 0.5,3.0);
move2 -> center.setValue(2.0,-2.0,1.0);
move2 -> scaleFactor.setValue(0.3, 2.0, 0.3);
move2 -> translation.setValue(0.0,4.0,0.0);
move2 -> scaleOrientation.setValue(30.0,23.0,-300.0,10.0);
move3 -> translation.setValue(0.0,2.0,0.0);
move3 -> scaleFactor.setValue(3.0, 0.50, 3.0);
move3 -> rotation.setValue(60.0,0.0,0.0,170.0);
move3 -> center.setValue(-1,2,1);
move3 -> scaleOrientation.setValue(-30.0,-23.0,300.0,-10.0);

As it has all effects, it is a little bit complex. SoTransform is executed by the following order:
  1. center
  2. scaleOrientation
  3. scaleFactor
  4. rotation
  5. translation
"center.setValue(x,y,z);" moves the objects. this is executed first, so this influences scale and rotation fields.
"scaleOrientation.setValue(x,y,z);" is like "scaleFactor.setValue(x,y,z);", but this field is applied first. So this influences the rotation field.
"rotation.setValue(x,y,z,k);" decides the angle of rotation.
use: hasira->addChild(move1); hasira ->addChild(myColor); hasira->addChild(new SoCylinder); root ->addChild(hasira); maru -> addChild(move2); maru ->addChild(yourColor); maru ->addChild(new SoSphere); root ->addChild(maru); sankaku -> addChild(move3); sankaku -> addChild(herColor); sankaku ->addChild(new SoCone); root -> addChild(sankaku);

C++ code



SoRotationXYZ

SoRotationXYZ changes the x, y, and z angles.

Graphics



include file #include <Inventor/nodes/SoRotationXYZ.h>
declarationSoRotationXYZ *kakudo1 = new SoRotationXYZ;
SoRotationXYZ *kakudo2 = new SoRotationXYZ;
SoRotationXYZ *kakudo3 = new SoRotationXYZ;
field(attribute) kakudo1 -> angle = M_PI/4;
kakudo1 -> axis = SoRotationXYZ::Y;
kakudo2 -> angle = M_PI/4;
kakudo2 -> axis = SoRotationXYZ::X;
kakudo3 -> angle = M_PI/4;
kakudo3 -> axis = SoRotationXYZ::Z

"angle = M_PI/4;" decides the degree 45 for rotation and
"axis = SoRotationXYZ::Y;" decides the axis for ratation Y.
use: sikaku1 -> addChild(kakudo1); sikaku1 -> addChild(herColor); sikaku1 ->addChild(new SoCube); root -> addChild(sikaku1); sikaku2 -> addChild(kakudo2); sikaku2 -> addChild(herColor); sikaku2 ->addChild(new SoCube); root -> addChild(sikaku2); sikaku3 -> addChild(kakudo3); sikaku3 -> addChild(herColor); sikaku3 ->addChild(new SoCube); root -> addChild(sikaku3);

C++ code



SoRotation

SoRotation changes x, y, and z angles.

Graphics



include file #include <Inventor/nodes/SoRotation.h>
declarationSoRotation *kakudo1 = new SoRotation;
SoRotation *kakudo2 = new SoRotation;
field(attribute)kakudo1 -> rotation.setValue(-260.0, -100.0, -45.0, M_PI/2);
kakudo2 -> rotation.setValue(260.0, 0.0, 0.0, 0.0);

"rotation.setValue(x,y,z,k);" decides the x, y, and z rotation angle. For example, rotation.setValue(1.0, 0.0, 0.5, 3.14); rotates 180 degrees around x axis, and 90 degrees around z axis. You can use M_PI instead of 3.14: rotation.setValue(1.0, 0.0, 0.5, M_PI);

use: sui1 -> addChild(kakudo1); sui1 -> addChild(iro); sui1 ->addChild(new SoCone); root -> addChild(sui1); sui2 -> addChild(kakudo2); sui2 -> addChild(iro); sui2 ->addChild(new SoCone); root -> addChild(sui2);

C++ code




To the SoTransformation page

Back to home [an error occurred while processing this directive]