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"
|
2020-02-14 10:54:25 +00:00
|
|
|
#include "model.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
|
|
|
|
{
|
2018-09-23 21:17:31 +00:00
|
|
|
//Camera
|
2020-02-14 10:54:25 +00:00
|
|
|
TinyRender::Matrix m_viewMatrix;
|
|
|
|
TinyRender::Matrix m_projectionMatrix;
|
|
|
|
TinyRender::Matrix m_viewportMatrix;
|
2016-05-27 00:36:01 +00:00
|
|
|
btVector3 m_localScaling;
|
|
|
|
btVector3 m_lightDirWorld;
|
2018-09-23 21:17:31 +00:00
|
|
|
btVector3 m_lightColor;
|
|
|
|
float m_lightDistance;
|
|
|
|
float m_lightAmbientCoeff;
|
|
|
|
float m_lightDiffuseCoeff;
|
|
|
|
float m_lightSpecularCoeff;
|
|
|
|
|
|
|
|
//Model (vertices, indices, textures, shader)
|
2020-02-14 10:54:25 +00:00
|
|
|
TinyRender::Matrix m_modelMatrix;
|
|
|
|
TinyRender::Model* m_model;
|
2018-09-23 21:17:31 +00:00
|
|
|
//class IShader* m_shader; todo(erwincoumans) expose the shader, for now we use a default shader
|
|
|
|
|
|
|
|
//Output
|
|
|
|
|
|
|
|
TGAImage& m_rgbColorBuffer;
|
|
|
|
b3AlignedObjectArray<float>& m_depthBuffer; //required, hence a reference
|
|
|
|
b3AlignedObjectArray<float>* m_shadowBuffer; //optional, hence a pointer
|
|
|
|
b3AlignedObjectArray<int>* m_segmentationMaskBufferPtr; //optional, hence a pointer
|
2016-04-27 03:52:52 +00:00
|
|
|
|
2018-09-23 21:17:31 +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);
|
|
|
|
TinyRenderObjectData(TGAImage& rgbColorBuffer, b3AlignedObjectArray<float>& depthBuffer, b3AlignedObjectArray<float>* shadowBuffer, b3AlignedObjectArray<int>* segmentationMaskBuffer, int objectIndex, int linkIndex);
|
|
|
|
virtual ~TinyRenderObjectData();
|
|
|
|
|
2018-10-09 04:27:08 +00:00
|
|
|
void loadModel(const char* fileName, struct CommonFileIOInterface* fileIO);
|
2018-10-09 23:25:32 +00:00
|
|
|
void createCube(float HalfExtentsX, float HalfExtentsY, float HalfExtentsZ, struct CommonFileIOInterface* fileIO=0);
|
2018-09-23 21:17:31 +00:00
|
|
|
void registerMeshShape(const float* vertices, int numVertices, const int* indices, int numIndices, const float rgbaColor[4],
|
|
|
|
unsigned char* textureImage = 0, int textureWidth = 0, int textureHeight = 0);
|
|
|
|
|
2018-10-09 04:27:08 +00:00
|
|
|
void registerMesh2(btAlignedObjectArray<btVector3>& vertices, btAlignedObjectArray<btVector3>& normals, btAlignedObjectArray<int>& indices, struct CommonFileIOInterface* fileIO);
|
2018-09-23 21:17:31 +00:00
|
|
|
|
|
|
|
void* m_userData;
|
|
|
|
int m_userIndex;
|
|
|
|
int m_objectIndex;
|
|
|
|
int m_linkIndex;
|
* add textured models of ball.vtk (obj/mtl) and torus (obj/mtl) and cloth.
1) allow to render deformables in 'getCameraImage', for TinyRenderer (tested OK) and EGL (untested)
2) allow to have textures for deformables. See deformable_ball.py, deformable_anchor.py and deformable_torus.py for examples
3) deformables: allow to request simulation mesh data (even if there is a render mesh) See deformable_anchor.py for an example usage
data = p.getMeshData(clothId, -1, flags=p.MESH_DATA_SIMULATION_MESH)
4) fix deletion of deformables, thanks to Fychuyan, https://github.com/bulletphysics/bullet3/pull/3048
5) allow to enable and disable double-sided rendering, p.changeVisualShape(objectUid, linkIndex, flags=p.VISUAL_SHAPE_DOUBLE_SIDED)
6) fix GripperGraspExample, model not found
7) Fix deformable anchor not attaching to multibody with object unique id of 0
8) Fix issue with assignment of unique ids in TinyRenderer/EGL renderer (always use broadphase uid)
9) Avoid crash/issue of simulation with pinned vertices (mass 0) in btDeformableBackwardEulerObjective::applyExplicitForce
10) Store uv/normal in btSoftBody::RenderNode to allow textured meshes
11) (uncomment in btSoftBodyHelpers.cpp): dump vertices and indices in obj wavefront format, when loading a VTK file, for quicker creation of a (textured) surface mesh
12) allow interpolateRenderMesh also for old position-based soft bodies (not only the shiny new FEM deformables)
13) fix a few premake targets
14) update build_visual_studio_vr_pybullet_double_cmake.bat so it suits c:\python37 and installs locally
for local install of Bullet, see also this example https://github.com/erwincoumans/hello_bullet_cmake
2020-09-12 08:03:04 +00:00
|
|
|
bool m_doubleSided;
|
2018-09-23 21:17:31 +00:00
|
|
|
};
|
2016-04-27 03:52:52 +00:00
|
|
|
|
|
|
|
class TinyRenderer
|
|
|
|
{
|
2018-09-23 21:17:31 +00:00
|
|
|
public:
|
|
|
|
static void renderObjectDepth(TinyRenderObjectData& renderData);
|
|
|
|
static void renderObject(TinyRenderObjectData& renderData);
|
2016-04-27 03:52:52 +00:00
|
|
|
};
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
#endif // TINY_RENDERER_Hbla
|