Page 1 of 1

vector3d

Posted: Sat Mar 20, 2004 6:43 am
by Draco
is there a way of getting to the individual coordinate variables of a vector3df? I'm trying to get the individual x,y,z values so I can print them to a file but cant get it to work. I looked through the file and it tried accessing them with .X, .Y, and .Z, which looked like the thing to do, but it's not.

Posted: Sat Mar 20, 2004 9:04 am
by PadrinatoR
I do this:

m_fX = m_pSceneNode->getPosition().X;
m_fY = m_pSceneNode->getPosition().Y;
m_fZ = m_pSceneNode->getPosition().Z;

getPosition returns a ¿pointer? to the vector3df which indicates the position of the node.

Posted: Sat Mar 20, 2004 7:24 pm
by Draco
ok, that really makes sense, thanks a lot.

Posted: Sat Mar 20, 2004 7:48 pm
by Draco
that still wont work, maybe because I'm trying to use it on the camera. Here's my code.

Code: Select all

fprintf("coordinates","%f,%f,%f\n",camera->getPosition().X,
          camera->getPosition().Y,camera->getPosition().Z);

Posted: Sat Mar 20, 2004 8:01 pm
by PadrinatoR
That code is very strange because fprintf function is used to write data into a file. Its first parameter is a pointer to a FILE struct.
Then you only have to do this:
FILE *pFile = fopen("file.ext","w");
fprintf(pFile, "coordinates %f %f %f\n",camera->getPosition().X,camera->getPosition().Y,camera->getPosition().Z);
I think that should work :roll: