Cannot compile the RTS Camera example in the wiki

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
fukuda
Posts: 23
Joined: Mon May 14, 2007 6:32 pm
Location: Barcelona, Spain

Cannot compile the RTS Camera example in the wiki

Post by fukuda »

hi, I'm trying to include the wiki's RTS Camera into my project, to test it and expand its features.

But... The compiler fails with the SViewFrustrum object:

Code: Select all

#ifndef __RTSCamera__
#define __RTSCamera__

#include <IRR/irrlicht.h>

/*
-------------Original code by CMD Kewin---
*/

using namespace irr;

class RTSCamera : public scene::ICameraSceneNode
{
   public:
      RTSCamera(IrrlichtDevice* devicepointer,scene::ISceneNode* parent,scene::ISceneManager* smgr,s32 id,
         f32 rotateSpeed = -1000.0f,f32 zoomSpeed = 1000.0f,f32 translationSpeed = 1000.0f);

      virtual ~RTSCamera();

      //Events
      virtual bool OnEvent(SEvent event);
      virtual void OnPreRender();
      virtual void render();
      virtual void OnPostRender(u32 timeMs);

      //Setup
      virtual void setInputReceiverEnabled(bool enabled);
      virtual bool isInputReceiverEnabled();

      //Gets
      virtual const core::aabbox3d<f32>& getBoundingBox() const;
      virtual const core::matrix4& getProjectionMatrix();
      virtual const scene::SViewFrustrum* getViewFrustrum();
      virtual core::vector3df getTarget() const;
      virtual const core::matrix4& getViewMatrix();
      virtual core::vector3df getUpVector() const;
      virtual f32 getNearValue();
      virtual f32 getFarValue();
      virtual f32 getAspectRatio();
      virtual f32 getFOV();

      //Sets
      virtual void setNearValue(f32 zn);
      virtual void setFarValue(f32 zf);
      virtual void setAspectRatio(f32 aspect);
      virtual void setFOV(f32 fovy);
      virtual void setUpVector(const core::vector3df& pos);
      virtual void setProjectionMatrix(const core::matrix4& projection);
      virtual void setPosition(const core::vector3df& newpos);
      virtual void setTarget(const core::vector3df& newpos);

      //Helper Functions
      void pointCameraAtNode(scene::ISceneNode* selectednode);
      void setMinZoom(f32 amount);
      void setMaxZoom(f32 amount);

      //Type Return
      virtual scene::ESCENE_NODE_TYPE getType() { return scene::ESNT_CAMERA; }

   protected:
      //Properties
      core::vector3df Target;
      core::vector3df UpVector;
      core::matrix4 Projection;
      scene::SViewFrustrum View;
      core::matrix4 ViewArea;
      core::aabbox3d<f32> BBox;
      bool InputReceiverEnabled;
      core::dimension2d<f32> screenDim;
      f32 Fovy;      //Field of view, in radians.
      f32 Aspect;      //Aspect ratio.
      f32 ZNear;      //Value of the near view-plane.
      f32 ZFar;      //Z-value of the far view-plane.

      void recalculateProjectionMatrix();
      void recalculateViewArea();

   private:
      IrrlichtDevice* device;
      core::vector3df Pos;
      bool zooming,rotating,moving,translating;
      f32 zoomSpeed;
      f32 translateSpeed;
      f32 rotateSpeed;
      f32 rotateStartX, rotateStartY;
      f32 zoomStartX, zoomStartY;
      f32 translateStartX, translateStartY;
      f32 currentZoom;
      f32 rotX, rotY;
      core::vector3df oldTarget;
      core::vector2df MousePos;
      bool Keys[KEY_KEY_CODES_COUNT];
      bool MouseKeys[3];
      f32 targetMinDistance;
      f32 targetMaxDistance;

      enum MOUSE_BUTTON
      {
         MOUSE_BUTTON_LEFT,
         MOUSE_BUTTON_MIDDLE,
         MOUSE_BUTTON_RIGHT
      };

      void allKeysUp();
      void allMouseKeysUp();
      bool isKeyDown(s32 key);
      bool isMouseKeyDown(s32 key);
      void animate();
      void updateAnimationState();
};

#endif
1st, it says that 'SViewFrustrum' has no type (when its the type of the function getViewFrustrum)

2nd, at 'scene::SViewFrustrum View;' it says thet SViewFrustrum is not a valid type.
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

It is now SViewFrustum
fukuda
Posts: 23
Joined: Mon May 14, 2007 6:32 pm
Location: Barcelona, Spain

Post by fukuda »

Oh thanks, yes I was a bit dumb, well, now it only says that 'virtual const SViewFrustum* getViewFrustum()' (the engine one) is abstract and I cannot allocate a camera because of that.
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

Make sure that your class has that function somewhere.

Also, make sure you do this somewhere

Code: Select all

const SViewFrustum* RTSCamera::getViewFrustum()
{
  return View;
} 
Well, I think that's correct anyways, it's been a while since I fooled with it.
fukuda
Posts: 23
Joined: Mon May 14, 2007 6:32 pm
Location: Barcelona, Spain

Post by fukuda »

Nah, it didn't worked :(

it gives me the same error

Code: Select all

const SViewFrustum* RTSCamera::getViewFrustum()
{
   return ViewArea;
}


it's ViewArea, btw
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

Not sure I can help much more then, heh. Sorry.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

I guess the const should be AFTER the parameters, for the whole method being const.
Post Reply