vector3d

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Draco
Posts: 14
Joined: Sat Mar 13, 2004 8:55 pm

vector3d

Post 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.
PadrinatoR
Posts: 50
Joined: Tue Mar 09, 2004 9:53 pm
Location: Spain

Post 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.
There are only 10 types of people: those who understand binary and those who don't

--------------------------------------------

Image
Draco
Posts: 14
Joined: Sat Mar 13, 2004 8:55 pm

Post by Draco »

ok, that really makes sense, thanks a lot.
Draco
Posts: 14
Joined: Sat Mar 13, 2004 8:55 pm

Post 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);
PadrinatoR
Posts: 50
Joined: Tue Mar 09, 2004 9:53 pm
Location: Spain

Post 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:
There are only 10 types of people: those who understand binary and those who don't

--------------------------------------------

Image
Post Reply