87 lines
2.1 KiB
C++
87 lines
2.1 KiB
C++
#ifndef IOBJECT_H__
|
|
#define IOBJECT_H__
|
|
|
|
#include "LString.h"
|
|
#include "render/IMaterialProxy.h"
|
|
#include "Globals.h"
|
|
#include "math/LifeMath.h"
|
|
#include "IGraphicsNode.h"
|
|
#include "camera/Camera.h"
|
|
|
|
namespace LifeGraphics
|
|
{
|
|
struct PER_OBJECT_CONSTANTS
|
|
{
|
|
LifeMath::float4x4 mWorld;
|
|
};
|
|
|
|
class Submesh
|
|
{
|
|
public:
|
|
String name;
|
|
int offset;
|
|
int length;
|
|
};
|
|
class IObject : public IGraphicsNode
|
|
{
|
|
protected:
|
|
IMaterialProxy** materials;
|
|
Submesh* subsets;
|
|
IConstantBuffer* perObjectCb;
|
|
IConstantBuffer* materialCb;
|
|
|
|
public:
|
|
IObject()
|
|
{
|
|
perObjectCb = CG::me()->GetRenderer()->CreateConstantBuffer(sizeof(PER_OBJECT_CONSTANTS));
|
|
}
|
|
virtual ~IObject(){}
|
|
virtual void bind() = 0;
|
|
virtual int getSumbeshCount() const = 0;
|
|
virtual void setMaterial(IMaterial* mat, int submesh, bool genShaders) = 0;
|
|
Submesh* getSubmesh(int id)
|
|
{
|
|
return subsets + id;
|
|
}
|
|
const IMaterialProxy* getMaterial(int submesh) const
|
|
{
|
|
return materials[submesh];
|
|
}
|
|
IMaterialProxy* getMaterial(int submesh)
|
|
{
|
|
return materials[submesh];
|
|
}
|
|
/*const IMaterial* getMaterial(String submesh) const
|
|
{
|
|
int count = getSumbeshCount();
|
|
for(int i = 0; i < count; i++)
|
|
{
|
|
if(*getSubmeshName(i) == submesh)
|
|
return materials + i;
|
|
}
|
|
return NULL;
|
|
}
|
|
IMaterial* getMaterial(String submesh)
|
|
{
|
|
int count = getSumbeshCount();
|
|
for(int i = 0; i < count; i++)
|
|
{
|
|
if(*getSubmeshName(i) == submesh)
|
|
return materials + i;
|
|
}
|
|
return NULL;
|
|
}*/
|
|
|
|
//virtual const String* getSubmeshName(int submesh) const = 0;
|
|
//virtual const LifeMath::float3intersect(const LifeMath::float3& rayStart, const LifeMath::float3& rayDir) const = 0;
|
|
//virtual const LifeMath::float3intersectSubmesh(const LifeMath::float3& rayStart, const LifeMath::float3& rayDir, int submesh) const = 0;
|
|
//virtual const LifeMath::float3intersectSubmesh(const LifeMath::float3& rayStart, const LifeMath::float3& rayDir, const String& submesh) const = 0;
|
|
virtual void selectLod(int lodNum) = 0;
|
|
virtual void selectLod(const Camera* cam) = 0;
|
|
virtual void render(int submesh) = 0;
|
|
//virtual int getVertexCount(int submesh) = 0;
|
|
//virtual int getFaceCount(int submesh) = 0;
|
|
};
|
|
}
|
|
|
|
#endif |