Dirk Scheffter (scheff++at++ue.iff.fhg.de)
Tue, 11 May 1999 15:12:44 -0600
unfortunately I cannot answer all of your questions but a few.
getPos() returns the local position. If you want to have the global position
then you have to multiply the position with the DCSs and SCSs by yourself.
The following is out of a sample I have written to deal with local and global
positions (concerning only DCSs). OrigPos shows local position. AbsPos shows
calculated global position.
// set up test scene graph
pfScene *scene = new pfScene;
pfNode *node = pfdLoadFile("cube-red.flt");
scene->addChild(node);
pfDCS *dcs1 = new pfDCS;
dcs1->setTrans(1, 1, 0);
dcs1->setRot(90, 0, 0);
dcs1->setScale(2, 2, 2);
scene->addChild(dcs1);
pfNode *node1 = pfdLoadFile("cube-green.flt");
dcs1->addChild(node1);
pfDCS *dcs2 = new pfDCS;
dcs2->setTrans(1, 0, 1);
dcs1->addChild(dcs2);
pfNode *node2 = pfdLoadFile("cube-blue.flt");
dcs2->addChild(node2);
// compute absolute position
pfMatrix mat;
pfCoord coord; coord.xyz.set(1, 2, 3); coord.hpr.set(0, 0, 0);
printf("OrigPos: %f %f %f %f %f %f\n",
coord.xyz[PF_X], coord.xyz[PF_Y], coord.xyz[PF_Z],
coord.hpr[PF_H], coord.hpr[PF_P], coord.hpr[PF_R]);
mat.makeCoord(&coord);
for (pfGroup *group = dcs2; group; group = group->getParent(0)) {
if (pfIsOfType(group, pfDCS::getClassType())) {
mat = mat * *((pfDCS*)group)->getMatPtr();
}
}
mat.getOrthoCoord(&coord);
printf("AbsPos: %f %f %f %f %f %f\n",
coord.xyz[PF_X], coord.xyz[PF_Y], coord.xyz[PF_Z],
coord.hpr[PF_H], coord.hpr[PF_P], coord.hpr[PF_R]);
BTW. in the quadrupel XYZW = (0.0, 0.0, 1.0, 0.0)
means you have a light at infinite distance directing downwards (W == 0.0).
For local lights you have to set W != 0.0 for example W = 1.0.
If you use a pfLightSource you can insert it into the scene graph because it is
derived from pfNode. (pfLights is derived from pfObject.)
Hope this helps a little bit.
Greetings,
Dirk.
-- ----------------------------------------------------------- Dipl.-Inf. Dirk Scheffter scheff++at++iff.fhg.de Fraunhofer IFF fon: +49 (0) 391/40 90-854 Sandtorstr. 22 fax: +49 (0) 391/40 90-870 D-39106 Magdeburg http://wwwue.iff.fhg.de/~scheff Germany ----------< Try this: http://wwwue.iff.fhg.de/ibft/mowib >-
This archive was generated by hypermail 2.0b2 on Tue May 11 1999 - 06:13:27 PDT