I have created Scene node class responsible to draw Gizmo.
I have w few questions about this class. I feel that me solution is not the right one.
1) how I should use scene Nodes inside another Scene node class. In my code I add scene node to scene manager class in constructor, what function Render should look like?
2) how to draw this gizmo in scale/zoom independent way. I want it to be the same size no matter what zoom/camera distance is?
3) is this correct to use using namespace in header file if it is surrounded by anonym namespace? in c++11
Thanks in advance for point me what is wrong in following implementation.
Code: Select all
#pragma once
#include "irrlicht.h"
namespace
{
using namespace irr;
using namespace video;
using namespace core;
using namespace scene;
class GizmoNode : public scene::ISceneNode
{
ISceneNode * baseNode;
public:
GizmoNode(scene::ISceneNode* parent, scene::ISceneManager* smgr, s32 id=-1) : scene::ISceneNode(parent, smgr, id)
{
auto colorS = SColor(255, 200, 200, 0);
const u32 teselCylinder = 4;
const u32 teselCone = 8;
const f32 height = 10.0;
const f32 cylinderHeight = 6.0f;
const f32 widthCylinder = 0.4f;
const f32 widthCone = 2.0f;
baseNode = smgr->addEmptySceneNode(this);
auto meshX = smgr->addArrowMesh("AxisX", colorS, SColor(255, 200, 0, 0),teselCylinder,teselCone,height,cylinderHeight,widthCylinder,widthCone );
auto arrowX = smgr->addAnimatedMeshSceneNode(meshX, baseNode);
arrowX->setMaterialFlag(video::EMF_LIGHTING, false);
arrowX->setRotation(vector3df(90, 90, 0));
auto meshY = smgr->addArrowMesh("AxisY", colorS, SColor(255, 0, 200, 0),teselCylinder,teselCone,height,cylinderHeight,widthCylinder,widthCone );
auto arrowY = smgr->addAnimatedMeshSceneNode(meshY, baseNode);
arrowY->setMaterialFlag(video::EMF_LIGHTING, false);
arrowY->setRotation(vector3df(0, 0, 0));
auto meshZ = smgr->addArrowMesh("AxisZ", colorS, SColor(255, 0, 0, 200),teselCylinder,teselCone,height,cylinderHeight,widthCylinder,widthCone );
auto arrowZ = smgr->addAnimatedMeshSceneNode(meshZ, baseNode);
arrowZ->setMaterialFlag(video::EMF_LIGHTING, false);
arrowZ->setRotation(vector3df(90, 0, 0));
}
virtual void OnRegisterSceneNode()
{
if (IsVisible) SceneManager->registerNodeForRendering(this);
ISceneNode::OnRegisterSceneNode();
}
virtual void render()
{
}
virtual const core::aabbox3d<f32>& getBoundingBox() const
{
return baseNode->getBoundingBox();
}
virtual u32 getMaterialCount() const
{
return baseNode->getMaterialCount();
}
virtual video::SMaterial& getMaterial(u32 i)
{
return baseNode->getMaterial(i);
}
};
}