Extreme noob traversing the turtorials

Get answers to all your basic programming questions. No Ogre questions, please!
Ein
Gnoblar
Posts: 3
Joined: Fri Jan 28, 2005 9:00 pm

Extreme noob traversing the turtorials

Post by Ein »

I'm going through turtorial 8 and am up to the point where it instructs me to
In the body of the constructor we need to assign the passed arguments to the proper variables.
I have exactly 0 knowledge of c++ / oo, only a minimal grasp on c, and I assume this is pretty obvious.

If somebody can point me in the right direction, it would be greatly appreciated. Even with my limited knowledge I managed to make a 2d minigame with the dx9sdk, but for some reason I'm just not grasping this.

This is my turtorialframelistener.cpp file (spaceframelistener.cpp in my project)

Code: Select all

#include "spaceframelistener.h"

SpaceFrameListener::SpaceFrameListener(RenderWindow* win, Camera* cam,
    SceneNode* controlNode,
    SceneNode* shipNode,
    SceneNode* cameraNode)
{ 
   mControlNode = controlNode; 
   mShipNode = shipNode; 
   mCameraNode = cameraNode; 
   mbFirstPerson = false; 
} 


bool SpaceFrameListener::frameStarted(const FrameEvent& evt)
{
    Real MoveFactor = 80.0 * evt.timeSinceLastFrame;

	mInputDevice->capture();

    if(mInputDevice->isKeyDown(Ogre::KC_UP))
        mControlNode->translate(0.0, MoveFactor, 0.0);
    if(mInputDevice->isKeyDown(Ogre::KC_DOWN))
        mControlNode->translate(0.0, -MoveFactor, 0.0);
    if(mInputDevice->isKeyDown(Ogre::KC_LEFT))
        mControlNode->translate(-MoveFactor, 0.0, 0.0);
    if(mInputDevice->isKeyDown(Ogre::KC_RIGHT))
        mControlNode->translate(MoveFactor, 0.0, 0.0);
	if(mInputDevice->isKeyDown(Ogre::KC_F))
	{
	    while (mInputDevice->isKeyDown(Ogre::KC_F))
			mInputDevice->capture();
		if (mbFirstPerson)
		{
	        // third person
		    mCameraNode->setPosition( Vector3( 0, 50, -200) );
			mbFirstPerson = false;
		}
		else
		{
	        // first person
		    mCameraNode->setPosition( Vector3( 0, 5, 40) );
			mbFirstPerson = true;
		};
	};
    if (mInputDevice->isKeyDown( KC_ESCAPE))
    {
        return false;
    }
    return true;
}
and my spaceframelistener.h

Code: Select all

#pragma once
#include "c:\cpp\ogrenew\samples\common\include\exampleframelistener.h"


class SpaceFrameListener : public ExampleFrameListener
{
protected:
    SceneNode* mControlNode;
    SceneNode* mShipNode;
    SceneNode* mCameraNode;
	bool mbFirstPerson;
public:
    SpaceFrameListener(RenderWindow* win, Camera* cam,
    SceneNode* controlNode,
    SceneNode* shipNode,
    SceneNode* cameraNode);
    bool frameStarted(const FrameEvent& evt);
};
I'm getting
c:\cpp\ogrenew\Samples\Space3\SpaceFrameListener.cpp(7): error C2512: 'ExampleFrameListener' : no appropriate default constructor available
User avatar
DWORD
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 1365
Joined: Tue Sep 07, 2004 12:43 pm
Location: Aalborg, Denmark

Post by DWORD »

You need to add a line to the constructor so it becomes:

Code: Select all

SpaceFrameListener::SpaceFrameListener(RenderWindow* win, Camera* cam, 
    SceneNode* controlNode, 
    SceneNode* shipNode, 
    SceneNode* cameraNode)
  : ExampleFrameListener(win, cam) // <--- add this line
{ 
   mControlNode = controlNode; 
   mShipNode = shipNode; 
   mCameraNode = cameraNode; 
   mbFirstPerson = false; 
}
I'm short of time, so I didn't read the complete tutorial. Maybe this needs to be added, if I did not miss it. The error you get is because the compiler don't know how to intialize the ExampleFrameListener if you don't pass on the 'win', and 'cam' parameters.
Ein
Gnoblar
Posts: 3
Joined: Fri Jan 28, 2005 9:00 pm

Post by Ein »

That did it!
Thanks a lot, now I can get back to pretending I know what I'm doing!

I think ogre might be my toy of choice from now on, being able to render a 3d scene with less code and hassle than it took to draw a sprite with dx9 is no small feat.