custom ISceneNode problem??

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
danielmccarthy
Posts: 51
Joined: Fri May 30, 2014 12:55 am

custom ISceneNode problem??

Post by danielmccarthy »

Hi I want to create a health scene node and I have used the custom scene node from the tutorials to start me off but their is a rendering problem? The onRegisterSceneNode method is not being called neither is the render.

Code: Select all

#include "CHealthBar.h"
#include <iostream>
 
using namespace std;
 
    CHealthBar::CHealthBar(scene::ISceneNode* parent, scene::ISceneManager* smgr, s32 id)
        : scene::ISceneNode(parent, smgr, id)
    {
        this->smgr = smgr;
 
        Material.Wireframe = false;
        Material.Lighting = false;
 
        Vertices[0] = video::S3DVertex(0,0,10, 1,1,0,
                video::SColor(255,0,255,255), 0, 1);
        Vertices[1] = video::S3DVertex(10,0,-10, 1,0,0,
                video::SColor(255,255,0,255), 1, 1);
        Vertices[2] = video::S3DVertex(0,20,0, 0,1,1,
                video::SColor(255,255,255,0), 1, 0);
        Vertices[3] = video::S3DVertex(-10,0,-10, 0,0,1,
                video::SColor(255,0,255,0), 0, 0);
 
        Box.reset(Vertices[0].Pos);
        for (s32 i=1; i<4; ++i)
            Box.addInternalPoint(Vertices[i].Pos);
    }
 
    CHealthBar::~CHealthBar()
    {
 
    }
    void CHealthBar::OnRegisterSceneNode()
    {
        if (IsVisible)
            SceneManager->registerNodeForRendering(this);
 
        ISceneNode::OnRegisterSceneNode();
        cout << "Test" << endl;
    }
 
    void CHealthBar::render()
    {
        cout << "Testing" << endl;
        u16 indices[] = {   0,2,3, 2,1,3, 1,0,3, 2,0,1  };
        video::IVideoDriver* driver = smgr->getVideoDriver();
 
        driver->setMaterial(Material);
        driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
        driver->drawVertexPrimitiveList(&Vertices[0], 4, &indices[0], 4, video::EVT_STANDARD, scene::EPT_TRIANGLES, video::EIT_16BIT);
    }
 
 
    const core::aabbox3d<f32>& CHealthBar::getBoundingBox() const
    {
        return Box;
    }
 
    u32 CHealthBar::getMaterialCount() const
    {
        return 1;
    }
 
    video::SMaterial& CHealthBar::getMaterial(u32 i)
    {
        return Material;
    }
 

Code: Select all

 
    CHealthBar* healthBar = new CHealthBar(this->getObjSceneNode(), this->smgr, 0);
    healthBar->setParent(this->getObjSceneNode());
    healthBar->setPosition(core::vector3df(0, 1, 0));
 
    healthBar->addAnimator(anim);
    anim->drop();
Help please?

Thanks
zerochen
Posts: 273
Joined: Wed Jan 07, 2009 1:17 am
Location: Germany

Re: custom ISceneNode problem??

Post by zerochen »

hi,

is the parent scenenode null? if so you have to set the rootscenenode as parent.
http://irrlicht.sourceforge.net/docu/cl ... c23f78635f

regards
zerochen
Seven
Posts: 1034
Joined: Mon Nov 14, 2005 2:03 pm

Re: custom ISceneNode problem??

Post by Seven »

also, you dont show the header file, but those functions need to be virtual
danielmccarthy
Posts: 51
Joined: Fri May 30, 2014 12:55 am

Re: custom ISceneNode problem??

Post by danielmccarthy »

they are set virtual in the header. And no the parent scene node is not NULL. I don't know why this is happening. The render method is not being called at all
Seven
Posts: 1034
Joined: Mon Nov 14, 2005 2:03 pm

Re: custom ISceneNode problem??

Post by Seven »

If you post an entire minimal app we can help
Matix522
Posts: 15
Joined: Wed Jul 02, 2014 11:48 am
Location: Poland

Re: custom ISceneNode problem??

Post by Matix522 »

you must turn of automatic culling. its should help.

Code: Select all

 
 healthBar->setAutomaticCulling(false)
 
or in constructor

Code: Select all

 
CHealthBar::CHealthBar(scene::ISceneNode* parent, scene::ISceneManager* smgr, s32 id, bool culling)
     : scene::ISceneNode(parent, smgr, id)
{
    ISceneNode::setAutomaticCulling(culling);
    //rest of your code
}
 
Post Reply