i need help to make my own class (solved)

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
noals
Posts: 70
Joined: Sun May 18, 2008 2:59 pm

i need help to make my own class (solved)

Post by noals »

hi,

first of all, for those who noticed, few times i posted and then deleted my post, its just that i found the answers to my questions so if there is no answer yet, i just delete, sorry if it annoyed some, dunno, just telling.

anyway, i try to make my own class and since im not familiar with the whole process, im kinda stuck already.
here is my code :

ImyRagdollSceneNode.h

Code: Select all

#ifndef __I_MY_RAGDOLL_SCENE_NODE__H__
#define __I_MY_RAGDOLL_SCENE_NODE__H__
 
#include <irrlicht.h>
 
using namespace irr;
 
namespace irr
{
    namespace scene
    {
        class ImyRagdollSceneNode : public ISceneNode
        {
            //defined by user
            core::vector3df ragPosition;
            core::vector3df ragRotation;
            u32 ragState;
            u32 ragID;
 
            //calculated in .cpp
 
////////////////////////////////////////////////////////
///////////////      BODY PART       ///////////////////
////////////////////////////////////////////////////////
            //torso
            core::vector3df torsoPos;
            core::vector3df torsoRot;
            u32 torsoID;
            //belly
            core::vector3df bellyPos;
            core::vector3df bellyRot;
            u32 bellyID;
            //bottom
            core::vector3df bottomPos;
            core::vector3df bottomRot;
            u32 bottomID;
            //head
            core::vector3df headPos;
            core::vector3df headRot;
            u32 headID;
            //right upper arm
            core::vector3df r_up_armPos;
            core::vector3df r_up_armRot;
            u32 r_up_armID;
            //right lower arm
            core::vector3df r_low_armPos;
            core::vector3df r_low_armRot;
            u32 r_low_armID;
            //right hand
            core::vector3df r_handPos;
            core::vector3df r_handRot;
            u32 r_handID;
            //left upper arm
            core::vector3df l_up_armPos;
            core::vector3df l_up_armRot;
            u32 l_up_armID;
            //left lower arm
            core::vector3df l_low_armPos;
            core::vector3df l_low_armRot;
            u32 l_low_armID;
            //left hand
            core::vector3df l_handPos;
            core::vector3df l_handRot;
            u32 l_handID;
            //right upper leg
            core::vector3df r_up_legPos;
            core::vector3df r_up_legRot;
            u32 r_up_legID;
            //right lower arm
            core::vector3df r_low_legPos;
            core::vector3df r_low_legRot;
            u32 r_low_legID;
            //right feet
            core::vector3df r_feetPos;
            core::vector3df r_feetRot;
            u32 r_feetID;
            //left upper leg
            core::vector3df l_up_legPos;
            core::vector3df l_up_legRot;
            u32 l_up_legID;
            //left lower leg
            core::vector3df l_low_legPos;
            core::vector3df l_low_legRot;
            u32 l_low_legID;
            //left feet
            core::vector3df l_feetPos;
            core::vector3df l_feetRot;
            u32 l_feetID;
        
////////////////////////////////////////////////////////
///////////////     BODY JOINT       ///////////////////
////////////////////////////////////////////////////////
            //torso_belly
            core::vector3df torso_bellyPos;
            core::vector3df torso_bellyRot;
            //torso_neck
            core::vector3df torso_neckPos;
            core::vector3df torso_neckRot;
            //belly_botom
            core::vector3df belly_bottomPos;
            core::vector3df belly_bottomRot;
            //torso_right_upper_arm
            core::vector3df torso_r_up_armPos;
            core::vector3df torso_r_up_armRot;
            //right_upper_arm_right_lower_arm
            core::vector3df r_up_arm_r_low_armPos;
            core::vector3df r_up_arm_r_low_armRot;
            //right_lower_arm_right_hand
            core::vector3df r_low_arm_r_handPos;
            core::vector3df r_low_arm_r_handRot;
            //torso_left_upper_arm
            core::vector3df torso_l_up_armPos;
            core::vector3df torso_l_up_armRot;
            //left_upper_arm_left_lower_arm
            core::vector3df l_up_arm_l_low_armPos;
            core::vector3df l_up_arm_l_low_armRot;
            //left_lower_arm_left_hand
            core::vector3df l_low_arm_l_handPos;
            core::vector3df l_low_arm_l_handRot;
            //bottom_right_upper_leg
            core::vector3df bottom_r_up_legPos;
            core::vector3df bottom_r_up_legRot;
            //right_upper_leg_righ_lower_leg
            core::vector3df r_up_leg_r_low_legPos;
            core::vector3df r_up_leg_r_low_legRot;
            //right_lower_leg_right_feet
            core::vector3df r_low_leg_r_feetPos;
            core::vector3df r_low_leg_r_feetRot;
            //bottom_left_upper_leg
            core::vector3df bottom_l_up_legPos;
            core::vector3df bottom_l_up_legRot;
            //left_upper_leg_left_lower_leg
            core::vector3df l_up_leg_l_low_legPos;
            core::vector3df l_up_leg_l_low_legRot;
            //left_lower_leg_left_feet
            core::vector3df l_low_leg_l_feetPos;
            core::vector3df l_low_leg_l_feetRot;
        
            public:
            //albator
            ImyRagdollSceneNode
            (
                core::vector3df ragPosition,        //ragdoll position
                core::vector3df ragRotation,        //ragdoll rotation
                u32 ragState,                       //ragdoll state, animation
                u32 ragID,                          //ragdoll ID
                scene::ISceneManager* smgr,         //pointer
                scene::ISceneNode* parent = 0,      //parent node
                s32 id = -1                     //ID
            );
 
            //minotaur
            ~ImyRagdollSceneNode();
 
            //frame
            virtual void OnRegisterSceneNode();
 
            //render
            virtual void render();
        };
    }
}
 
#endif
ImyRagdollSceneNode.cpp

Code: Select all

#include <irrlicht.h>
#include "ImyRagdollSceneNode.h"
 
namespace irr
{
    namespace scene
    {
        //albator
        ImyRagdollSceneNode::ImyRagdollSceneNode
        (
            core::vector3df ragPosition,        //ragdoll position
            core::vector3df ragRotation,        //ragdoll rotation
            u32 ragState,                       //ragdoll state, animation
            u32 ragID,                          //ragdoll ID
            scene::ISceneManager* smgr,         //pointer
            scene::ISceneNode* parent = 0,      //parent node
            s32 id = -1                         //ID
        ): ISceneNode(smgr->getRootSceneNode(), smgr, id)
        {
            //DO THE RAGDOLL
        }
 
        //minotaur
        ImyRagdollSceneNode::~ImyRagdollSceneNode(){}
 
        //frame
        void ImyRagdollSceneNode::OnRegisterSceneNode()
        {
            if (IsVisible)SceneManager->registerNodeForRendering(this);
            ISceneNode::OnRegisterSceneNode();
        }
 
        //render ragdoll
        void ImyRagdollSceneNode::render()
        {
            video::IVideoDriver* driver = SceneManager->getVideoDriver();
            if (!driver) return;
        }
    }
}
and how i try to use it :

Code: Select all

 
    //ragdoll test
    scene::ImyRagdollSceneNode*myRagdoll = new scene::ImyRagdollSceneNode(
        core::vector3df (0.0f,0.0f,0.0f),       //ragdoll position
        core::vector3df (0.0f,0.0f,0.0f),       //ragdoll rotation
        0,                                      //ragdoll state, animation
        0,                                      //ragdoll ID
        smgr,               //pointer
        0,                  //parent node
        -1);                    //ID
but vc++ underlign the second "scene" and tell me:
object of abstract class type "irr::scene::ImyRagdollSceneNode" is not allowed
on an irc channel someone told me that it could be a missing virtual void stuff()=0; but i dont really understand.
did i forgot something before trying to make any calculs and stuff ?
can someone help me fixing it ?
Last edited by noals on Sun Oct 14, 2012 7:02 pm, edited 3 times in total.
Puck6633
Posts: 27
Joined: Wed Aug 10, 2005 8:35 am

Re: i need help to make my own class

Post by Puck6633 »

The specific error you're getting is due to the fact that Irrlicht defines several member functions of the ISceneNode class that are "pure virtual" functions. This means that the compiler has been told to expect these functions to be defined in any sub class of ISceneNode, but they haven't actually been defined as of yet. That error is the compiler telling you "your class has functions that should be defined but aren't, so I can't instantiate it."

The functions I had to implement in my custom scene node were:

Code: Select all

 
void OnRegisterSceneNode(); //You have this already
void render(); //And this
u32 getMaterialCount();
SMaterial& getMaterial(u32 i);
aabbox3df& getBoundingBox();
 
I hope that helps!
noals
Posts: 70
Joined: Sun May 18, 2008 2:59 pm

Re: i need help to make my own class

Post by noals »

i just needed to add the bounding box.
i have problems of redefinition now because of my .cpp but i know how to fix it.

thx for help.
noals
Posts: 70
Joined: Sun May 18, 2008 2:59 pm

Re: i need help to make my own class

Post by noals »

well i though i was able to solve it but the problem is a little different than what i had in mind.
1> ImyRagdollSceneNode.cpp
1>ImyRagdollSceneNode.cpp(18): error C2572: 'irr::scene::ImyRagdollSceneNode::ImyRagdollSceneNode' : redefinition of default parameter : parameter 7
1> d:\crea4\projets\demo_iii\demo_iii\ImyRagdollSceneNode.h(145) : see declaration of 'irr::scene::ImyRagdollSceneNode::ImyRagdollSceneNode'
1>ImyRagdollSceneNode.cpp(18): error C2572: 'irr::scene::ImyRagdollSceneNode::ImyRagdollSceneNode' : redefinition of default parameter : parameter 6
1> d:\crea4\projets\demo_iii\demo_iii\ImyRagdollSceneNode.h(145) : see declaration of 'irr::scene::ImyRagdollSceneNode::ImyRagdollSceneNode'

from .cpp

Code: Select all

namespace irr
{
    namespace scene
    {
        //albator
        ImyRagdollSceneNode::ImyRagdollSceneNode
        (
            core::vector3df IragPosition,       //ragdoll position
            core::vector3df IragRotation,       //ragdoll rotation
            u32 IragState,                      //ragdoll state, animation
            u32 IragID,                         //ragdoll ID
            ISceneManager* smgr,            //pointer
            ISceneNode* parent = 0,     //parent node
            s32 id = -1                         //ID
        ): ISceneNode(smgr->getRootSceneNode(), smgr, id) //this iine is the problem
        {
            //init
            ragPosition=IragPosition;
            ragRotation=IragRotation;
            ragState=IragState;
            ragID=IragID;
        }
from .h

Code: Select all

            public:
            //albator
            ImyRagdollSceneNode
            (  //this line is the problem 
                core::vector3df ragPosition,        //ragdoll position
                core::vector3df ragRotation,        //ragdoll rotation
                u32 ragState,                       //ragdoll state, animation
                u32 ragID,                          //ragdoll ID
                ISceneManager* smgr,            //pointer
                ISceneNode* parent = 0,         //parent node
                s32 id = -1                     //ID
            );
i guess my smgr isnt initialized well or something, any idea ?
noals
Posts: 70
Joined: Sun May 18, 2008 2:59 pm

Re: i need help to make my own class

Post by noals »

well i will use another class from irrlicht 1.7.3 as exemple i think.
actualy i was able to make a class like that working years ago (my first class ever and im trying my second lol) but it was also with an old version of irrlich so i guess its maybe the source of my problem since i use my old class as exemple.

i will try again from the start.
zerochen
Posts: 273
Joined: Wed Jan 07, 2009 1:17 am
Location: Germany

Re: i need help to make my own class (solved)

Post by zerochen »

1>ImyRagdollSceneNode.cpp(18): error C2572: 'irr::scene::ImyRagdollSceneNode::ImyRagdollSceneNode' : redefinition of default parameter : parameter 7
default parameter belong to the header file not to the source file
noals
Posts: 70
Joined: Sun May 18, 2008 2:59 pm

Re: i need help to make my own class (solved)

Post by noals »

default parameter belong to the header file not to the source file
thx a lot, it compiled. :D

i just had to change that :

Code: Select all

            ISceneNode* parent = 0,     //parent node
            s32 id = -1                         //ID
to that :

Code: Select all

            ISceneNode* parent,     //parent node
            s32 id                        //ID
im glad it was this simple, i dont have to do it all again and can continu my stuff, thx again.
Post Reply