2016-04-27 03:47:10 +00:00
|
|
|
#ifndef __MODEL_H__
|
|
|
|
#define __MODEL_H__
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
#include "geometry.h"
|
|
|
|
#include "tgaimage.h"
|
|
|
|
|
2020-02-14 10:54:25 +00:00
|
|
|
namespace TinyRender
|
|
|
|
{
|
2018-09-23 21:17:31 +00:00
|
|
|
class Model
|
|
|
|
{
|
2016-04-27 03:47:10 +00:00
|
|
|
private:
|
2018-09-23 21:17:31 +00:00
|
|
|
std::vector<Vec3f> verts_;
|
|
|
|
std::vector<std::vector<Vec3i> > faces_; // attention, this Vec3i means vertex/uv/normal
|
|
|
|
std::vector<Vec3f> norms_;
|
|
|
|
std::vector<Vec2f> uv_;
|
|
|
|
TGAImage diffusemap_;
|
|
|
|
TGAImage normalmap_;
|
|
|
|
TGAImage specularmap_;
|
|
|
|
Vec4f m_colorRGBA;
|
|
|
|
|
|
|
|
void load_texture(std::string filename, const char* suffix, TGAImage& img);
|
|
|
|
|
2016-04-27 03:47:10 +00:00
|
|
|
public:
|
2018-09-23 21:17:31 +00:00
|
|
|
Model(const char* filename);
|
|
|
|
Model();
|
|
|
|
void setColorRGBA(const float rgba[4])
|
|
|
|
{
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
m_colorRGBA[i] = rgba[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
const Vec4f& getColorRGBA() const
|
|
|
|
{
|
|
|
|
return m_colorRGBA;
|
|
|
|
}
|
|
|
|
void loadDiffuseTexture(const char* relativeFileName);
|
|
|
|
void setDiffuseTextureFromData(unsigned char* textureImage, int textureWidth, int textureHeight);
|
2016-07-14 07:05:57 +00:00
|
|
|
void reserveMemory(int numVertices, int numIndices);
|
2018-09-23 21:17:31 +00:00
|
|
|
void addVertex(float x, float y, float z, float normalX, float normalY, float normalZ, float u, float v);
|
|
|
|
void addTriangle(int vertexposIndex0, int normalIndex0, int uvIndex0,
|
|
|
|
int vertexposIndex1, int normalIndex1, int uvIndex1,
|
|
|
|
int vertexposIndex2, int normalIndex2, int uvIndex2);
|
2016-04-27 03:47:10 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
~Model();
|
|
|
|
int nverts();
|
2020-09-20 23:03:56 +00:00
|
|
|
int nnormals()
|
|
|
|
{
|
|
|
|
return norms_.size();
|
|
|
|
}
|
2018-09-23 21:17:31 +00:00
|
|
|
int nfaces();
|
* 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
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
Vec3f normal(int iface, int nthvert);
|
|
|
|
Vec3f normal(Vec2f uv);
|
|
|
|
Vec3f vert(int i);
|
|
|
|
Vec3f vert(int iface, int nthvert);
|
* 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
|
|
|
Vec3f* readWriteVertices()
|
|
|
|
{
|
|
|
|
if (verts_.size() == 0)
|
|
|
|
return 0;
|
|
|
|
return &verts_[0];
|
|
|
|
}
|
2020-09-20 23:03:56 +00:00
|
|
|
|
|
|
|
Vec3f* readWriteNormals()
|
|
|
|
{
|
|
|
|
if (norms_.size() == 0)
|
|
|
|
return 0;
|
|
|
|
return &norms_[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
Vec2f uv(int iface, int nthvert);
|
|
|
|
TGAColor diffuse(Vec2f uv);
|
|
|
|
float specular(Vec2f uv);
|
|
|
|
std::vector<int> face(int idx);
|
|
|
|
};
|
2020-02-14 10:54:25 +00:00
|
|
|
}
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
#endif //__MODEL_H__
|