Page 1 of 1

My Collision Problem

Posted: Fri Aug 17, 2007 3:01 pm
by dejai
Ok, now I want the camera to move or be repositioned when it hits a certain corrd

Code: Select all

   scene::ISceneNode* camera = smgr->addCameraSceneNodeFPS();
   
   if (camera)
   {
            camera->setPosition(vector3df(0,150,-100));
            camera->setRotation(vector3df(0,90,0));
            vector3df position = camera->getPosition();
           vector3df wall_1 = vector3df(0,100,-100);
           
           if (wall_1 == position)
           {
                   
           camera->setPosition(vector3df(0,100,0));    
           }
           
        
   }

Now, I want this line of code

Code: Select all

           if (wall_1 == position)
           {
                   
           camera->setPosition(vector3df(0,100,0));    
           }
           
to only apply to the middle level z

so no matter where i am say 34,100,2
or 734,100,2 it will always stop the camera

so whenever the camera gets to the point 100 on axis z it just stops.

Posted: Fri Aug 17, 2007 3:07 pm
by hybrid
Do you know the concept of continuing a previous thread?

Posted: Fri Aug 17, 2007 3:09 pm
by dejai
Also how do I get some cords showing in the top left corner of the screen.

vector3df position = camera->getPosition();

That position for example

Posted: Fri Aug 17, 2007 4:31 pm
by hybrid
The middle value of 3d vector is called y, not z. You can compare elements of vectors just as you compare vectors by using '=='.
Use core::stringw(number) to create strings from numbers, and combine the numbers to a complete string. Then use .c _str() when passing it to a CGUIStaticText.

Posted: Fri Aug 17, 2007 5:30 pm
by Acki
well, to compare just a single axis compare the single axis:

Code: Select all

if (wall_1.Y == position.Y)
but I think this wont work this way, how great is the possibility that you get exactly at this point with float or even double values ?!?!?!? :shock: it's nearly zero !!! :lol:
better this way:

Code: Select all

if (wall_1.Y >= position.Y)
or in your case it should be:

Code: Select all

if (position.Y >= wall_1.Y)
You are now about 4 month working with Irrlicht and still don't know such elementary coding stuff ??? :lol: shame on you :lol:

Posted: Fri Aug 24, 2007 5:08 pm
by webnoob
Just a little bit off topic, but still some good general advice.

Learn at least some basic coding techniques. I am very new to C++, in fact I have merely printed something to a screen before starting on Irrlicht (3 days ago), but my experience in other languages gives me the grasp on what I want to do, I just need to learn the syntax.

Find some basic programming tutorials and start experimenting more than you are, that way people will be more inclined to help you as they know that you are trying, which seems more that you are doing now.

WebNoob

Posted: Sat Aug 25, 2007 6:17 am
by dejai
I understand A wide range of the C++ language more than you. But this is my first API so meh.

Posted: Sat Aug 25, 2007 6:23 am
by dejai
Not really 4 months, i have been registered a while but I only use this sometimes on weekends so :{

Posted: Sat Aug 25, 2007 7:14 am
by dejai
I am getting their but this is not working it compiles but it does not work

Code: Select all

   scene::ISceneNode* camera = smgr->addCameraSceneNodeFPS();
   
   if (camera)
   {
            camera->setPosition(vector3df(0,150,-100));
            camera->setRotation(vector3df(0,90,0));
            vector3df position = camera->getPosition();
          
                        
        
   }
   
 vector3df position = camera->getPosition();
 vector3df wall_1 = vector3df (100,100,100);
  


	


	int lastFPS = -1;

	while(device->run())
	if (device->isWindowActive())
	{
          if (position.Z >=wall_1.Z )
          {
            camera->setPosition(vector3df(0,100,0));           
                       }                       





IS their a way to set .Z postion etc?