Tutorial code compiling problem

Problems building or running the engine, queries about how to use features etc.
Post Reply
smonijhay
Halfling
Posts: 90
Joined: Mon Feb 07, 2005 6:03 pm

Tutorial code compiling problem

Post by smonijhay »

Hi, as I have learned from debugging many errors with the tutorial code, the tutorial is outdated!!

I'm stuck on this one error that I can't seem to find on the forums. Do you think you can help me?

I'm running the full source from the second half of the "Humble Beginnnings" tutorial. I went through and fixed all the yaw and rotate errors (thanks forums! :D ). The error I'm left with when I build is

Code: Select all

error C2440: '=' : cannot convert from 'class Ogre::Node *' to 'class Ogre::SceneNode *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.
The line in question that throws this error is

Code: Select all

	mRotatingNode = mCentralNode->createChild();
and the full section of code is

Code: Select all

class SpaceCameraRotator : public ExampleFrameListener
{
protected:
	Camera* mCamera;
	SceneNode* mCentralNode;
	SceneNode* mRotatingNode;
	Vector3 mRotationAxis;
	Real mRotationSpeed;

public:
	SpaceCameraRotator(RenderWindow* win, Camera* cam, SceneNode* centralNode, Vector3 initialPosition) : ExampleFrameListener(win, cam)
	{
		mCamera = cam;
		mCentralNode = centralNode;
		mRotationAxis = Vector3::UNIT_Y;
		mRotationSpeed = 60.0;

		// Create a node to act as the central rotation point
		mRotatingNode = mCentralNode->createChild();

		mRotatingNode->attachObject(mCamera);//this line right,tutorial wrong
		mCamera->moveRelative(initialPosition);
		mCamera->lookAt(0, 0, 0);
	}

	~SpaceCameraRotator()
	{
		delete mRotatingNode;
	}

    bool frameStarted(const FrameEvent& evt)
    {
		// Copy the current state of the input devices
		mInputDevice->capture();

		if(mInputDevice->isKeyDown(Ogre::KC_SPACE))
		  mRotatingNode->rotate(mRotationAxis, Degree(mRotationSpeed * evt.timeSinceLastFrame));  //tutorial wrong, this is right		

		return true;
	}

};
If this isn't enough information, please let me know. and thanks for the help!
User avatar
haffax
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 4823
Joined: Fri Jun 18, 2004 1:40 pm
Location: Berlin, Germany
x 8
Contact:

Post by haffax »

Two options.
casting the result of createChild():

Code: Select all

mRotatingNode = static_cast<SceneNode*>(mCentralNode->createChild());
using the SceneNode functions:

Code: Select all

mRotatingNode = mCentralNode->createChildSceneNode();
The second way is preferred.
team-pantheon programmer
creators of Rastullahs Lockenpracht
smonijhay
Halfling
Posts: 90
Joined: Mon Feb 07, 2005 6:03 pm

Post by smonijhay »

Hi tanis,

Thanks for the help. Unfortunately when I tried each option, I ended up with more errors and a few warnings!

Code: Select all

Compiling...
Space.cpp
c:\cygwin\home\X\ogrenew\samples\space\spaceapplication.h(520) : error C2440: '=' : cannot convert from 'class Ogre::Node *' to 'class Ogre::SceneNode *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
c:\cygwin\home\X\ogrenew\samples\space\spaceapplication.h(555) : error C2039: 'attachLight' : is not a member of 'SceneNode'
        c:\cygwin\home\X\ogrenew\ogremain\include\ogrescenenode.h(45) : see declaration of 'SceneNode'
c:\cygwin\home\X\ogrenew\samples\space\spaceapplication.h(562) : error C2039: 'attachLight' : is not a member of 'SceneNode'
        c:\cygwin\home\X\ogrenew\ogremain\include\ogrescenenode.h(45) : see declaration of 'SceneNode'
c:\cygwin\home\X\ogrenew\samples\space\spaceapplication.h(569) : error C2039: 'attachLight' : is not a member of 'SceneNode'
        c:\cygwin\home\X\ogrenew\ogremain\include\ogrescenenode.h(45) : see declaration of 'SceneNode'
c:\cygwin\home\X\ogrenew\samples\space\spaceapplication.h(573) : error C2259: 'LightFlasher' : cannot instantiate abstract class due to following members:
        c:\cygwin\home\X\ogrenew\samples\space\spaceapplication.h(258) : see declaration of 'LightFlasher'
c:\cygwin\home\X\ogrenew\samples\space\spaceapplication.h(573) : warning C4259: 'float __thiscall Ogre::ControllerValue<float>::getValue(void) const' : pure virtual function was not defined
        c:\cygwin\home\X\ogrenew\ogremain\include\ogrecontroller.h(97) : see declaration of 'getValue'
c:\cygwin\home\X\ogrenew\samples\space\spaceapplication.h(573) : error C2259: 'LightFlasher' : cannot instantiate abstract class due to following members:
        c:\cygwin\home\X\ogrenew\samples\space\spaceapplication.h(258) : see declaration of 'LightFlasher'
c:\cygwin\home\X\ogrenew\samples\space\spaceapplication.h(573) : warning C4259: 'float __thiscall Ogre::ControllerValue<float>::getValue(void) const' : pure virtual function was not defined
        c:\cygwin\home\X\ogrenew\ogremain\include\ogrecontroller.h(97) : see declaration of 'getValue'
c:\cygwin\home\X\ogrenew\samples\space\spaceapplication.h(574) : error C2259: 'LightFlasher' : cannot instantiate abstract class due to following members:
        c:\cygwin\home\X\ogrenew\samples\space\spaceapplication.h(258) : see declaration of 'LightFlasher'
c:\cygwin\home\X\ogrenew\samples\space\spaceapplication.h(574) : warning C4259: 'float __thiscall Ogre::ControllerValue<float>::getValue(void) const' : pure virtual function was not defined
        c:\cygwin\home\X\ogrenew\ogremain\include\ogrecontroller.h(97) : see declaration of 'getValue'
c:\cygwin\home\X\ogrenew\samples\space\spaceapplication.h(575) : error C2259: 'LightBlinker' : cannot instantiate abstract class due to following members:
        c:\cygwin\home\X\ogrenew\samples\space\spaceapplication.h(295) : see declaration of 'LightBlinker'
c:\cygwin\home\X\ogrenew\samples\space\spaceapplication.h(575) : warning C4259: 'float __thiscall Ogre::ControllerValue<float>::getValue(void) const' : pure virtual function was not defined
        c:\cygwin\home\X\ogrenew\ogremain\include\ogrecontroller.h(97) : see declaration of 'getValue'
c:\cygwin\home\X\ogrenew\samples\space\spaceapplication.h(575) : error C2259: 'LightBlinker' : cannot instantiate abstract class due to following members:
        c:\cygwin\home\X\ogrenew\samples\space\spaceapplication.h(295) : see declaration of 'LightBlinker'
c:\cygwin\home\X\ogrenew\samples\space\spaceapplication.h(575) : warning C4259: 'float __thiscall Ogre::ControllerValue<float>::getValue(void) const' : pure virtual function was not defined
        c:\cygwin\home\X\ogrenew\ogremain\include\ogrecontroller.h(97) : see declaration of 'getValue'
c:\cygwin\home\X\ogrenew\samples\space\spaceapplication.h(584) : error C2664: 'createController' : cannot convert parameter 2 from 'class LightFlasher *' to 'class Ogre::SharedPtr<class Ogre::ControllerValue<float> >'
        No constructor could take the source type, or constructor overload resolution was ambiguous
c:\cygwin\home\X\ogrenew\samples\space\spaceapplication.h(585) : error C2664: 'createController' : cannot convert parameter 2 from 'class LightFlasher *' to 'class Ogre::SharedPtr<class Ogre::ControllerValue<float> >'
        No constructor could take the source type, or constructor overload resolution was ambiguous
c:\cygwin\home\X\ogrenew\samples\space\spaceapplication.h(586) : error C2664: 'createController' : cannot convert parameter 2 from 'class LightFlasher *' to 'class Ogre::SharedPtr<class Ogre::ControllerValue<float> >'
        No constructor could take the source type, or constructor overload resolution was ambiguous
Error executing cl.exe.

Space.exe - 12 error(s), 5 warning(s)
Is there anything else that I can do?
User avatar
haffax
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 4823
Joined: Fri Jun 18, 2004 1:40 pm
Location: Berlin, Germany
x 8
Contact:

Post by haffax »

The conversion of the tutorial seems not to be trivial obviously.

attachLight(), attachCamera() & co are removed. Just use attachObject(), SceneNode figures out itself now what you actually attached.

For the other problem look in this thread.

Alternativly you can wait till after the weekend, for Sinbad will then revise the tutorials, to get them working with Ogre 1.0.
team-pantheon programmer
creators of Rastullahs Lockenpracht
smonijhay
Halfling
Posts: 90
Joined: Mon Feb 07, 2005 6:03 pm

Post by smonijhay »

Thanks tanis for you help! It definitely got me further than I was before. I think I may hang out until this weekend, see what sinbad may have in store for us noobies!

thanks again! :D
Post Reply