Files

102 lines
1.9 KiB
C++
Raw Permalink Normal View History

2025-05-13 02:46:21 +03:00
#ifndef IGraphicsNode_h__
#define IGraphicsNode_h__
#include "math/LifeMath.h"
#include <vector>
#include <BoundingBox3D.h>
#include "BoundingSphere.h"
#include <ITransform.h>
#include "LString.h"
namespace LifeGraphics
{
enum NodeType
{
NT_CAMERA, NT_LIGHT, NT_MESH, NT_PARTICLE_SYSTEM, NT_TERRAIN, NT_SCENE_ROOT
};
class IGraphicsNode
{
protected:
LifeCore::ITransform* defaultTransform;
LifeCore::ITransform* transform;
private:
public:
long Id;
String Name;
std::vector<IGraphicsNode*> childs;
IGraphicsNode* parent;
bool castShadows;
LifeCore::BoundingBox3D bBox;
BoundingSphere bSphere;
LifeMath::float3 transformedBox[8];
const LifeCore::BoundingBox3D* getBoundingBox()
{
return &bBox;
}
const LifeMath::float3* getTransformedBox()
{
//if(!transform->IsValid())
//{
bBox.GetCorners(transformedBox);
LifeMath::float4x4 mTransform = transform->GetMatrix();
for(int i = 0; i<8; i++)
{
transformedBox[i] = Vec3TransformCoordinate( mTransform, transformedBox[i]);
}
//}
return transformedBox;
}
const BoundingSphere* getBoundingSphere()
{
return &bSphere;
}
LifeCore::ITransform* getTransform()
{
return transform;
}
void SetTransform(LifeCore::ITransform* _transform)
{
transform = _transform;
}
void setParent(IGraphicsNode* node)
{
parent = node;
}
IGraphicsNode* getParent()
{
return parent;
}
IGraphicsNode()
:castShadows(true)
{
defaultTransform = new LifeCore::ITransform();
transform = defaultTransform;
}
virtual ~IGraphicsNode()
{
if(defaultTransform)
{
delete defaultTransform;
defaultTransform = NULL;
}
transform = NULL;
}
void addChild(IGraphicsNode* node)
{
childs.push_back(node);
node->setParent(this);
}
virtual NodeType getType() = 0;
virtual void update(float timeElapsed) = 0;
};
}
#endif // ISceneNode_h__