Creating a new camera

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
Endar
Posts: 145
Joined: Mon Jun 14, 2004 7:59 am

Creating a new camera

Post by Endar »

I'm trying to create a "new" camera using the FPS camera, and I was inheriting from CCameraFPSSceneNode, and then I realised that I would have to inherit from ICameraSceneNode because the camera functions in the scene manager all take ICameraSceneNode*. So, I thought to inherit from ICameraSceneNode, then CCameraFPSSceneNode.

Now, this doens't work because ICameraSceneNode is the base class of CCameraFPSSceneNode.

So, while inheriting from just CCameraFPSSceneNode how can I have the class as ICameraSceneNode? Should I just create an FPS camera and leave a pointer to it in the private part of my class definition?
"The reputation of a thousand years may be determined by the conduct of one hour."
-Japanese Proverb
ManakelNotYetAwake

Post by ManakelNotYetAwake »

Maybe i didn't understand the point but if your C inherit from A that inherit From B, it's safe to cast C to B in CPP, isnt'it?

So you dont need the pointer ?
Endar
Posts: 145
Joined: Mon Jun 14, 2004 7:59 am

Post by Endar »

That's good, but I'm just not sure how to do it. Because my class is called something and then when I create one and then try to use setActiveCamera(ICameraSceneNode*) , it obviously gives me an error that my class isn't the right type, so do I just cast it? eg. setActiveCamera( (ICameraSceneNode*) camera); ???

And just another thing, I'm inheriting from CCameraFPSSceneNode obviously so I don't have to re-write all the code that my mathematical and other skills just aren't up to, and well, I'm getting linking errors for what appears to be all the functons in the CCameraFPSSceneNode class.

Code: Select all

RTSCamera::RTSCamera(irr::f32 r, irr::f32 r_limit, irr::f32 h, irr::IrrlichtDevice* device, irr::f32 angleY, irr::core::vector3df start_pivot)

: irr::scene::CCameraFPSSceneNode(NULL, device->getSceneManager(), device->getCursorControl(), -1, 1500.0f, 200.0f,0,0 )
That was the first couple of lines (just before the start of the body) of my constructor class. and in the class definiton (header file) I have inherited from the class with " class RTSCamera : public irr::scene::CCameraFPSSceneNode", and I have included the cpp and header files for the class.

So, if you were able to follow all that :shock: if you have any suggestions, don't hesitate to beat me over the head with them. :D
"The reputation of a thousand years may be determined by the conduct of one hour."
-Japanese Proverb
NovaCoder
Posts: 28
Joined: Wed May 26, 2004 11:36 am
Contact:

Post by NovaCoder »

Don't inherit from the FPS camera, it prob won't contain anything useful to your new class.

Code: Select all

declaration:

class CCameraEditorSceneNode : public CCameraSceneNode

definition:
CCameraEditorSceneNode::CCameraEditorSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id,
	 f32 rs, f32 zs, f32 ts)
: CCameraSceneNode(parent, mgr, id)
Then update ISceneManager.h to:

Code: Select all

	virtual ICameraSceneNode* addCameraSceneNodeEditor(ISceneNode* parent = 0,
			f32 rotateSpeed = -1500.0f, f32 zoomSpeed = 200.0f, f32 translationSpeed = 1500.0f, s32 id=-1) = 0;
Not sure if this the best/only way but it seems to work.
- Nova
Post Reply