Beam scenenode Help!

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
empirepro
Posts: 71
Joined: Thu Dec 27, 2007 5:41 am

Beam scenenode Help!

Post by empirepro »

I am trying to use the beam scenenode. I put the wrapper into a header file called laser.h and then call it in my main.cpp I get over 120 errors with it and yet I just copied and pasted as it was giving here on the forum!

Code: Select all

// Just a simple wrapper :D
struct IrrQuad {
   video::S3DVertex verts[4];
};

class CBeamNode : public scene::ISceneNode {
   private:
      // The beam material.
      video::SMaterial material;

      // Start/End Points
      core::vector3df vStart;
      core::vector3df vEnd;

      // Bounding Box
      core::aabbox3d<f32> Box;

      // Size of the beam
      float flScale;

      // Beam color
      video::SColor beamColor;

      void DrawQuad( IrrQuad& quad ) {
         u16 indices[] = { 0,2,3, 2,1,3, 1,0,3, 2,0,1 };
         video::IVideoDriver* driver = SceneManager->getVideoDriver();
         driver->setMaterial(material);
         driver->drawIndexedTriangleList( &quad.verts[0], 4, &indices[0], 4 );
      }

      // Thanks to whoever wrote this little function :)
      core::vector3df getTargetAngle( core::vector3df v, core::vector3df r) {
         //v -current node position
         //r -target node position

         core::vector3df angle;
         float x,y,z;
         x = r.X - v.X;
         y = r.Y - v.Y;
         z = r.Z - v.Z;

         //angle in X-Z plane
         angle.Y = atan2 (x, z);
         angle.Y *= (180 / 3.14); //converting from rad to degrees

         //just making sure angle is somewhere between 0-360 degrees
         if(angle.Y < 0) angle.Y += 360;
         if(angle.Y >= 360) angle.Y -= 360;

         //angle in Y-Z plane while Z and X axes are already rotated around Y
         float z1 = sqrt(x*x + z*z);

         angle.X = atan2 (z1, y);
         angle.X *= (180 / 3.14); //converting from rad to degrees
         angle.X -= 90;

         //just making sure angle is somewhere between 0-360 degrees
         if(angle.X < 0) angle.X += 360;
         if(angle.X >= 360) angle.X -= 360;

         return angle;
      }

   public:

      CBeamNode( scene::ISceneNode* parent, scene::ISceneManager *mgr, s32 id, char* szBeam ) : scene::ISceneNode( parent, mgr, id ) {
         // Setup the beam material
         material.Wireframe = false;
         material.Lighting = false;
         material.MaterialType = video::EMT_TRANSPARENT_ADD_COLOR;
         material.Texture1 = mgr->getVideoDriver( )->getTexture( szBeam );

         // Default to 32 units for the scale
         flScale = 32.0;

         // Default to white
         beamColor.set( 255, 255, 255, 255 );
      }

      virtual void OnPreRender( ) {
         if( IsVisible ) {
            SceneManager->registerNodeForRendering( this );
         }
      }

      virtual void render( ) {
        SceneManager->getVideoDriver()->setTransform(irr::video::ETS_WORLD, AbsoluteTransformation);

         // Figure out quads based on start/end points.
         core::matrix4 m;
         m.setRotationDegrees( getTargetAngle( vStart, vEnd ) );
         core::vector3df vUp( 0, 1, 0 );
         core::vector3df vRight( -1, 0, 0 );
         m.transformVect( vRight );
         m.transformVect( vUp );

         // Draw the first cross
         IrrQuad beam;
         beam.verts[0] = video::S3DVertex( vStart + vUp * flScale, core::vector3df( 1, 1, 0 ), beamColor, core::vector2df( 0, 1 ) );
         beam.verts[1] = video::S3DVertex( vStart + vUp * -flScale, core::vector3df( 1, 0, 0 ), beamColor, core::vector2df( 1, 1 ) );
         beam.verts[2] = video::S3DVertex( vEnd + vUp * -flScale, core::vector3df( 0, 1, 1 ), beamColor, core::vector2df( 1, 0 ) );
         beam.verts[3] = video::S3DVertex( vEnd + vUp * flScale, core::vector3df( 0, 0, 1 ), beamColor, core::vector2df( 0, 0 ) );
         DrawQuad( beam );

         // Draw the second cross.
         beam.verts[0] = video::S3DVertex( vStart + vRight * flScale, core::vector3df( 1, 1, 0 ), beamColor, core::vector2df( 0, 1 ) );
         beam.verts[1] = video::S3DVertex( vStart + vRight * -flScale, core::vector3df( 1, 0, 0 ), beamColor, core::vector2df( 1, 1 ) );
         beam.verts[2] = video::S3DVertex( vEnd + vRight * -flScale, core::vector3df( 0, 1, 1 ), beamColor, core::vector2df( 1, 0 ) );
         beam.verts[3] = video::S3DVertex( vEnd + vRight * flScale, core::vector3df( 0, 0, 1 ), beamColor, core::vector2df( 0, 0 ) );
         DrawQuad( beam );
      }

      virtual const core::aabbox3d<f32>& getBoundingBox() const {
         return Box;
      }

      virtual s32 getMaterialCount() {
         return 1;
      }

      virtual video::SMaterial& getMaterial(s32 i) {
         return material;
      }

      void SetStartPoint( core::vector3df pos ) {
         vStart = pos;
      }

      void SetEndPoint( core::vector3df pos ) {
         vEnd = pos;
      }

      void SetBeamScale( float size ) {
         flScale = size;
      }

      void SetBeamColor( video::SColor color ) {
         beamColor = color;
      }
};
any ideas whats causing the errors?
twilight17
Posts: 362
Joined: Sun Dec 16, 2007 9:25 pm

Post by twilight17 »

What are the errors?
Post this userbar I made on other websites to show your support for Irrlicht!
Image
http://img147.imageshack.us/img147/1261 ... wernq4.png
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

The errors are probably related to source incompatible changes that have been made in the library since the original CBeamSceneNode code was written. I believe these changes have been covered in the changes.txt, but the signatures of many of the methods of ISceneNode have changed in the last year or so. For example OnPreRender() was renamed to OnRegisterSceneNode(), OnPostRender() became OnAnimate(), getMaterialCount() us now const and returns a u32, getMaterial() takes a u32...

If you look at the error messages your compiler gives you it is often possible to figure out what the problem is. That is why the compiler produces the messages in the first place...

Travis
empirepro
Posts: 71
Joined: Thu Dec 27, 2007 5:41 am

Post by empirepro »

here are the results from trying to compile

Code: Select all

------ Rebuild All started: Project: Final Conflict, Configuration: Debug Win32 ------
Deleting intermediate and output files for project 'Final Conflict', configuration 'Debug|Win32'
Compiling...
main.cpp
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(3) : error C2653: 'video' : is not a class or namespace name
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(3) : error C2146: syntax error : missing ';' before identifier 'verts'
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(3) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(3) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(6) : error C2653: 'scene' : is not a class or namespace name
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(6) : error C2504: 'ISceneNode' : base class undefined
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(9) : error C2653: 'video' : is not a class or namespace name
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(9) : error C2146: syntax error : missing ';' before identifier 'material'
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(9) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(9) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(12) : error C2653: 'core' : is not a class or namespace name
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(12) : error C2146: syntax error : missing ';' before identifier 'vStart'
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(12) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(12) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(13) : error C2653: 'core' : is not a class or namespace name
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(13) : error C2146: syntax error : missing ';' before identifier 'vEnd'
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(13) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(13) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(16) : error C2653: 'core' : is not a class or namespace name
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(16) : error C2143: syntax error : missing ';' before '<'
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(16) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(16) : error C2238: unexpected token(s) preceding ';'
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(22) : error C2653: 'video' : is not a class or namespace name
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(22) : error C2146: syntax error : missing ';' before identifier 'beamColor'
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(22) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(22) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(32) : error C2653: 'core' : is not a class or namespace name
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(32) : error C2146: syntax error : missing ';' before identifier 'getTargetAngle'
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(32) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(32) : error C2653: 'core' : is not a class or namespace name
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(32) : error C2061: syntax error : identifier 'vector3df'
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(32) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(62) : warning C4183: 'getTargetAngle': missing return type; assumed to be a member function returning 'int'
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(66) : error C2653: 'scene' : is not a class or namespace name
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(66) : error C2653: 'scene' : is not a class or namespace name
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(66) : error C2061: syntax error : identifier 'ISceneNode'
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(113) : error C2653: 'core' : is not a class or namespace name
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(113) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(113) : error C2143: syntax error : missing ';' before '<'
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(113) : error C2433: 'CBeamNode::aabbox3d' : 'virtual' not permitted on data declarations
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(113) : error C2334: unexpected token(s) preceding '{'; skipping apparent function body
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(117) : error C2146: syntax error : missing ';' before identifier 'getMaterialCount'
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(117) : error C2433: 'CBeamNode::s32' : 'virtual' not permitted on data declarations
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(117) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(117) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(119) : warning C4183: 'getMaterialCount': missing return type; assumed to be a member function returning 'int'
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(121) : error C2653: 'video' : is not a class or namespace name
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(121) : error C2143: syntax error : missing ';' before '&'
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(121) : error C2433: 'CBeamNode::SMaterial' : 'virtual' not permitted on data declarations
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(121) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(121) : error C2061: syntax error : identifier 's32'
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(121) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(123) : warning C4183: 'getMaterial': missing return type; assumed to be a member function returning 'int'
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(125) : error C2653: 'core' : is not a class or namespace name
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(125) : error C2061: syntax error : identifier 'vector3df'
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(129) : error C2653: 'core' : is not a class or namespace name
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(129) : error C2061: syntax error : identifier 'vector3df'
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(137) : error C2653: 'video' : is not a class or namespace name
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(137) : error C2061: syntax error : identifier 'SColor'
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(25) : error C2065: 'u16' : undeclared identifier
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(25) : error C2146: syntax error : missing ';' before identifier 'indices'
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(25) : error C2065: 'indices' : undeclared identifier
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(25) : error C2059: syntax error : ']'
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(25) : error C2143: syntax error : missing ';' before '{'
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(25) : error C2143: syntax error : missing ';' before '}'
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(26) : error C2653: 'video' : is not a class or namespace name
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(26) : error C2065: 'IVideoDriver' : undeclared identifier
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(26) : error C2065: 'driver' : undeclared identifier
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(26) : error C2065: 'SceneManager' : undeclared identifier
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(26) : error C2227: left of '->getVideoDriver' must point to class/struct/union/generic type
        type is ''unknown-type''
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(27) : error C2065: 'driver' : undeclared identifier
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(27) : error C2227: left of '->setMaterial' must point to class/struct/union/generic type
        type is ''unknown-type''
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(27) : error C2065: 'material' : undeclared identifier
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(28) : error C2065: 'driver' : undeclared identifier
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(28) : error C2227: left of '->drawIndexedTriangleList' must point to class/struct/union/generic type
        type is ''unknown-type''
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(28) : error C2039: 'verts' : is not a member of 'IrrQuad'
        c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(2) : see declaration of 'IrrQuad'
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(28) : error C2065: 'indices' : undeclared identifier
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(36) : error C2653: 'core' : is not a class or namespace name
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(36) : error C2065: 'vector3df' : undeclared identifier
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(36) : error C2146: syntax error : missing ';' before identifier 'angle'
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(36) : error C2065: 'angle' : undeclared identifier
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(38) : error C2065: 'r' : undeclared identifier
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(38) : error C2228: left of '.X' must have class/struct/union
        type is ''unknown-type''
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(38) : error C2065: 'v' : undeclared identifier
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(38) : error C2228: left of '.X' must have class/struct/union
        type is ''unknown-type''
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(39) : error C2065: 'r' : undeclared identifier
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(39) : error C2228: left of '.Y' must have class/struct/union
        type is ''unknown-type''
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(39) : error C2065: 'v' : undeclared identifier
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(39) : error C2228: left of '.Y' must have class/struct/union
        type is ''unknown-type''
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(40) : error C2065: 'r' : undeclared identifier
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(40) : error C2228: left of '.Z' must have class/struct/union
        type is ''unknown-type''
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(40) : error C2065: 'v' : undeclared identifier
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(40) : error C2228: left of '.Z' must have class/struct/union
        type is ''unknown-type''
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(43) : error C2065: 'angle' : undeclared identifier
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(43) : error C2228: left of '.Y' must have class/struct/union
        type is ''unknown-type''
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(44) : error C2065: 'angle' : undeclared identifier
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(44) : error C2228: left of '.Y' must have class/struct/union
        type is ''unknown-type''
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(47) : error C2065: 'angle' : undeclared identifier
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(47) : error C2228: left of '.Y' must have class/struct/union
        type is ''unknown-type''
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(47) : error C2065: 'angle' : undeclared identifier
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(47) : error C2228: left of '.Y' must have class/struct/union
        type is ''unknown-type''
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(48) : error C2065: 'angle' : undeclared identifier
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(48) : error C2228: left of '.Y' must have class/struct/union
        type is ''unknown-type''
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(48) : error C2065: 'angle' : undeclared identifier
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(48) : error C2228: left of '.Y' must have class/struct/union
        type is ''unknown-type''
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(53) : error C2065: 'angle' : undeclared identifier
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(53) : error C2228: left of '.X' must have class/struct/union
        type is ''unknown-type''
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(54) : error C2065: 'angle' : undeclared identifier
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(54) : error C2228: left of '.X' must have class/struct/union
        type is ''unknown-type''
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(55) : error C2065: 'angle' : undeclared identifier
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(55) : error C2228: left of '.X' must have class/struct/union
        type is ''unknown-type''
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(58) : error C2065: 'angle' : undeclared identifier
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(58) : error C2228: left of '.X' must have class/struct/union
        type is ''unknown-type''
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(58) : error C2065: 'angle' : undeclared identifier
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(58) : error C2228: left of '.X' must have class/struct/union
        type is ''unknown-type''
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(59) : error C2065: 'angle' : undeclared identifier
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(59) : error C2228: left of '.X' must have class/struct/union
        type is ''unknown-type''
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(59) : error C2065: 'angle' : undeclared identifier
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(59) : error C2228: left of '.X' must have class/struct/union
        type is ''unknown-type''
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(61) : error C2065: 'angle' : undeclared identifier
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(66) : error C2653: 'scene' : is not a class or namespace name
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(66) : error C2065: 'parent' : undeclared identifier
c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(66) : fatal error C1003: error count exceeds 100; stopping compilation
Build log was saved at "file://c:\Documents and Settings\James\Desktop\game development\irrlicht-1.4\examples\04.Movement\Debug\BuildLog.htm"
Final Conflict - 120 error(s), 3 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
Kriolyth
Posts: 26
Joined: Wed Mar 26, 2008 6:59 pm
Location: Moscow, Russia

Post by Kriolyth »

Have you forgotten a "using namespace irr;" line?
The cake is a lie.
empirepro
Posts: 71
Joined: Thu Dec 27, 2007 5:41 am

Post by empirepro »

No here is the first few lines of my main.cpp

Code: Select all

#include <irrlicht.h>
#include "laser.h"
#include <iostream>

using namespace irr;

double playerspeed = 0.0;

#pragma comment(lib, "Irrlicht.lib")
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

The first few lines of "laser.h" should be something like

Code: Select all

#include <irrlicht.h>
using namespace irr;
You should always include all necessary files in the file that uses them. If you don't, you'll get weird dependency errors like you've got in this example. Ideally you'd only include the necessary files, but for small projects that isn't necessary.

The other way to work around the problem is put the using clause immediately after the irrlicht include, but that doesn't actually fix the problem, it just works around it.
empirepro
Posts: 71
Joined: Thu Dec 27, 2007 5:41 am

Post by empirepro »

Ok thank you for telling me that I needed to include the files even in the header files I did not know that! It has now cleared up all of the errors however I am now getting a new error with this piece of coding:

Code: Select all

material.Texture1 = mgr->getVideoDriver( )->getTexture( szBeam );
the error is:

Code: Select all

c:\documents and settings\james\desktop\game development\irrlicht-1.4\examples\04.movement\laser.h(74) : error C2039: 'Texture' : is not a member of 'irr::video::SMaterial'
        c:\documents and settings\james\desktop\game development\irrlicht-1.4\include\smaterial.h(66) : see declaration of 'irr::video::SMaterial'
I have done a search on the forum about this topic and have come up empty!
cdrwolfe
Posts: 100
Joined: Thu Nov 15, 2007 5:38 pm
Location: Cranfield University

Post by cdrwolfe »

I do recall there being a problem with GetMaterial and 1.3.1 though i'am not sure if this is the one effecting you.

Code: Select all

public override Material GetMaterial(int i) // IMPORTANT, required for correct functionality due to bug in Irrlicht 1.3.1
        {
            return Material;
        }
The above code is in C# so can't be directly copied.

Regards Wolfe
empirepro
Posts: 71
Joined: Thu Dec 27, 2007 5:41 am

Post by empirepro »

I have the latest version of Irrlicht so I would think that they would have fixed the problem if they knew about it. However how would I translate that code into C++?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

You don't have to use that code or any similar, because your problem is that simply the direct access to the texture pointer is not accessible anymore. You have to use setTexture(n, texture) or access the material layer first to get the texture pointer.
empirepro
Posts: 71
Joined: Thu Dec 27, 2007 5:41 am

Post by empirepro »

Ok I have changed my code to:

Code: Select all

material.setTexture(0, texture) = mgr->getVideoDriver( )->getTexture( szBeam );
But now I am getting another error:

Code: Select all

error C2065: 'texture' : undeclared identifier
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Uh...

Code: Select all

video::ITexture* texture = mgr->getVideoDriver( )->getTexture( szBeam );
material.setTexture(0, texture);
empirepro
Posts: 71
Joined: Thu Dec 27, 2007 5:41 am

Post by empirepro »

Thank you! It now compiles no problem but nothing happens the way I want it to! I want to have it so that when you press the F button it fires so I have it setup like:

Code: Select all

if(keys[irr::KEY_KEY_F])
        {
			CBeamNode* beam = new CBeamNode( smgr->getRootSceneNode( ), smgr, 200, "laserbeam.bmp" );
beam->SetStartPoint( core::vector3df( -500, 0, 0 ) );
beam->SetEndPoint( core::vector3df( 500, 0, 0 ) );
beam->SetBeamColor( video::SColor( 255, 0, 255, 0 ) );
beam->SetBeamScale(2.0);
		}
Now I know that according to that code it will start at -500, 0, 0 so thats where I have my ship start from so I should be able to see it fire however it does not fire at all! Any ideas?
Post Reply