Page 1 of 1
Tutorial code compiling problem
Posted: Wed Feb 16, 2005 7:42 pm
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!

). 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!
Posted: Wed Feb 16, 2005 7:59 pm
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.
Posted: Wed Feb 16, 2005 8:20 pm
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?
Posted: Wed Feb 16, 2005 8:30 pm
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.
Posted: Wed Feb 16, 2005 10:16 pm
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!
