2016-04-27 03:52:52 +00:00
|
|
|
#ifndef TINY_RENDERER_H
|
|
|
|
#define TINY_RENDERER_H
|
|
|
|
|
2016-04-28 19:28:04 +00:00
|
|
|
#include "geometry.h"
|
2016-04-27 03:52:52 +00:00
|
|
|
#include "Bullet3Common/b3AlignedObjectArray.h"
|
2016-05-13 06:03:12 +00:00
|
|
|
#include "Bullet3Common/b3Vector3.h"
|
|
|
|
#include "LinearMath/btAlignedObjectArray.h"
|
|
|
|
#include "LinearMath/btVector3.h"
|
|
|
|
|
|
|
|
|
2016-04-28 19:28:04 +00:00
|
|
|
#include "tgaimage.h"
|
2016-04-27 03:52:52 +00:00
|
|
|
|
|
|
|
struct TinyRenderObjectData
|
|
|
|
{
|
|
|
|
//Camera
|
|
|
|
Matrix m_viewMatrix;
|
|
|
|
Matrix m_projectionMatrix;
|
|
|
|
Matrix m_viewportMatrix;
|
2016-05-27 00:36:01 +00:00
|
|
|
btVector3 m_localScaling;
|
|
|
|
btVector3 m_lightDirWorld;
|
2016-11-20 20:52:12 +00:00
|
|
|
btVector3 m_lightColor;
|
2016-11-29 19:11:41 +00:00
|
|
|
float m_lightDistance;
|
2016-12-06 23:21:35 +00:00
|
|
|
float m_lightAmbientCoeff;
|
|
|
|
float m_lightDiffuseCoeff;
|
|
|
|
float m_lightSpecularCoeff;
|
2016-05-18 06:57:19 +00:00
|
|
|
|
2016-04-27 03:52:52 +00:00
|
|
|
//Model (vertices, indices, textures, shader)
|
2016-04-28 19:28:04 +00:00
|
|
|
Matrix m_modelMatrix;
|
2016-04-27 03:52:52 +00:00
|
|
|
class Model* m_model;
|
|
|
|
//class IShader* m_shader; todo(erwincoumans) expose the shader, for now we use a default shader
|
|
|
|
|
|
|
|
//Output
|
2016-06-07 23:11:58 +00:00
|
|
|
|
2016-04-28 19:28:04 +00:00
|
|
|
TGAImage& m_rgbColorBuffer;
|
2016-08-12 21:18:46 +00:00
|
|
|
b3AlignedObjectArray<float>& m_depthBuffer;//required, hence a reference
|
2016-12-02 21:23:50 +00:00
|
|
|
b3AlignedObjectArray<float>* m_shadowBuffer;//optional, hence a pointer
|
2016-08-12 21:18:46 +00:00
|
|
|
b3AlignedObjectArray<int>* m_segmentationMaskBufferPtr;//optional, hence a pointer
|
2016-12-02 00:47:11 +00:00
|
|
|
|
|
|
|
TinyRenderObjectData(TGAImage& rgbColorBuffer,b3AlignedObjectArray<float>&depthBuffer);
|
|
|
|
TinyRenderObjectData(TGAImage& rgbColorBuffer,b3AlignedObjectArray<float>&depthBuffer,b3AlignedObjectArray<int>* segmentationMaskBuffer,int objectIndex);
|
|
|
|
TinyRenderObjectData(TGAImage& rgbColorBuffer,b3AlignedObjectArray<float>&depthBuffer,b3AlignedObjectArray<float>* shadowBuffer);
|
2017-12-28 18:18:35 +00:00
|
|
|
TinyRenderObjectData(TGAImage& rgbColorBuffer,b3AlignedObjectArray<float>&depthBuffer,b3AlignedObjectArray<float>* shadowBuffer, b3AlignedObjectArray<int>* segmentationMaskBuffer,int objectIndex, int linkIndex);
|
2016-04-27 03:52:52 +00:00
|
|
|
virtual ~TinyRenderObjectData();
|
|
|
|
|
2016-04-28 19:28:04 +00:00
|
|
|
void loadModel(const char* fileName);
|
|
|
|
void createCube(float HalfExtentsX,float HalfExtentsY,float HalfExtentsZ);
|
2016-06-02 00:47:41 +00:00
|
|
|
void registerMeshShape(const float* vertices, int numVertices,const int* indices, int numIndices, const float rgbaColor[4],
|
2016-05-18 06:57:19 +00:00
|
|
|
unsigned char* textureImage=0, int textureWidth=0, int textureHeight=0);
|
2016-05-13 06:03:12 +00:00
|
|
|
|
|
|
|
void registerMesh2(btAlignedObjectArray<btVector3>& vertices, btAlignedObjectArray<btVector3>& normals,btAlignedObjectArray<int>& indices);
|
2016-04-28 19:28:04 +00:00
|
|
|
|
|
|
|
void* m_userData;
|
|
|
|
int m_userIndex;
|
2016-08-11 21:55:30 +00:00
|
|
|
int m_objectIndex;
|
2017-12-28 18:18:35 +00:00
|
|
|
int m_linkIndex;
|
2016-04-27 03:52:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class TinyRenderer
|
|
|
|
{
|
|
|
|
public:
|
2016-11-28 00:53:15 +00:00
|
|
|
static void renderObjectDepth(TinyRenderObjectData& renderData);
|
2016-11-29 19:43:52 +00:00
|
|
|
static void renderObject(TinyRenderObjectData& renderData);
|
2016-04-27 03:52:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // TINY_RENDERER_Hbla
|