Horde3D

Next-Generation Graphics Engine
It is currently 22.11.2024, 07:29

All times are UTC + 1 hour




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: _cam node
PostPosted: 16.07.2008, 08:16 
Offline

Joined: 11.06.2008, 10:34
Posts: 119
Morning, ive modified one of the samples to load a HordeEditor scene instead of the other content, but im having some trouble with the camera.

Im a novice coder and to be honest this isn't my field, so im not sure what im doing at best.

At the moment the Camera is added to the Knight Sample Scene using the following:

Quote:
_cam = Horde3D::addCameraNode( RootNode, "Camera", _hdrPipeRes );


Then some further Camera Setting functions etc defined later on. Ideally I would like to use the Camera from the HordeEditor scene instead, but can't seem to figure out how to render it, and control. I assume I need to define it to the _cam = function (as thats the one rendered later on), but the nodes ive tried such as getNode doesn't obviously work.

I assume I need to pick the Camera node defined in the scene xml file.

Regards :)

_________________

Let's bring 'em out! Any old iron! Any old iron!
A door opens and a homewife brings out a rather sophisticated-looking ground-to-air missile system, and dumps it on the cart.
Thank you.


Top
 Profile  
Reply with quote  
 Post subject: Re: _cam node
PostPosted: 16.07.2008, 08:30 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
If you want to use the camera in the .scene.xml file created by the editor, you have to search for this node after loading the scene in your application. Therefore it is usally a good idea to give the camera a unique name. Then in the application's code you can use
Code:
int found = Horde3D::findNodes(RootNode, "CameraName", SceneNodeTypes::Camera);
if( found >= 1 )
  _cam = Horde3D::getNodeFindResult(0);


Top
 Profile  
Reply with quote  
 Post subject: Re: _cam node
PostPosted: 16.07.2008, 09:04 
Offline

Joined: 11.06.2008, 10:34
Posts: 119
Worked a charm, thanks.

_________________

Let's bring 'em out! Any old iron! Any old iron!
A door opens and a homewife brings out a rather sophisticated-looking ground-to-air missile system, and dumps it on the cart.
Thank you.


Top
 Profile  
Reply with quote  
 Post subject: Re: _cam node
PostPosted: 17.07.2008, 04:09 
Offline

Joined: 10.07.2008, 10:49
Posts: 20
hi guys,

Is there a function that does the collision checking as the one in the SceneEditor (in menu View->Camera collision check)?
I set this function in SceneEditor but it has no effect when I load the scene.


Top
 Profile  
Reply with quote  
 Post subject: Re: _cam node
PostPosted: 17.07.2008, 07:28 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
That's nothing that is implemented directly in Horde3D. It's only for the editor. But you can use castRay to check for collisions. See also the source code of the editor (cameraNavigationUpdate in GLWidget.cpp).


Top
 Profile  
Reply with quote  
 Post subject: Re: _cam node
PostPosted: 29.10.2008, 20:19 
Offline

Joined: 11.06.2008, 10:34
Posts: 119
Just a follow on from this topic - im having a problem where the camera location is not used from the scene.xml file unless I comment out the following from the Main Loop:

Code:
   // Set camera parameters
   Horde3D::setNodeTransform( _cam, _x, _y, _z, _rx ,_ry, 0, 1, 1, 1 );


However after doing so the camera is positioned correctly (using the position saved in the scene file), it then becomes unmovable from the key controls. Any cut & paste suggestions? :)

_________________

Let's bring 'em out! Any old iron! Any old iron!
A door opens and a homewife brings out a rather sophisticated-looking ground-to-air missile system, and dumps it on the cart.
Thank you.


Top
 Profile  
Reply with quote  
 Post subject: Re: _cam node
PostPosted: 29.10.2008, 21:34 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
No cut and paste solution. You have to initialize the _x _y _rx, etc. values with the transformation saved in the XML file.
If you comment out the line, you won't change the camera's transformation, so of course it's not possible to control it with the keyboard anymore.


Top
 Profile  
Reply with quote  
 Post subject: Re: _cam node
PostPosted: 29.10.2008, 21:36 
Offline

Joined: 11.06.2008, 10:34
Posts: 119
Right thanks, unfortunately that's beyond me.

_________________

Let's bring 'em out! Any old iron! Any old iron!
A door opens and a homewife brings out a rather sophisticated-looking ground-to-air missile system, and dumps it on the cart.
Thank you.


Top
 Profile  
Reply with quote  
 Post subject: Re: _cam node
PostPosted: 30.10.2008, 00:40 
Offline

Joined: 08.11.2006, 03:10
Posts: 384
Location: Australia
You could probably use getNodeTransform to initialize the values.

Somewhere before the main loop, set a flag to false:
Code:
bool initCam = false;

The replace the "Set camera parameters" code with this:
Code:
if( !initCam )
{
   initCam = true;
   float foo;//unused - don't care about getting all parameters
   // Get camera parameters
   Horde3D::getNodeTransform( _cam, &_x, &_y, &_z, &_rx ,&_ry, &foo, &foo, &foo, &foo );
}
else
{
   // Set camera parameters
   Horde3D::setNodeTransform( _cam, _x, _y, _z, _rx ,_ry, 0, 1, 1, 1 );
}


Top
 Profile  
Reply with quote  
 Post subject: Re: _cam node
PostPosted: 30.10.2008, 08:10 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
Thanks for the more detailed description, Darkangel.

BTW, you don't really need the foo variable. You could just pass 0 to the method and it won't get those parameters.


Top
 Profile  
Reply with quote  
 Post subject: Re: _cam node
PostPosted: 30.10.2008, 10:12 
Offline

Joined: 11.06.2008, 10:34
Posts: 119
Thank you DarkAngel! its working perfect :) for anyone else who doesn't really do coding like myself, don't forget to declare the function in app.h around line 36.

_________________

Let's bring 'em out! Any old iron! Any old iron!
A door opens and a homewife brings out a rather sophisticated-looking ground-to-air missile system, and dumps it on the cart.
Thank you.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 20 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group