mirror of
https://github.com/bulletphysics/bullet3.git
synced 2026-10-24 01:30:54 +00:00
Put TinyRender functions and classes inside a TinyRender namespace. The TinyRender library defines some classes with very generic names, such as vec, Matrix, Model, which in my case, when compiling the example browser using a different library for graphics, is giving me name clashes.
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
#include "our_gl.h"
|
||||
#include "tgaimage.h"
|
||||
|
||||
using namespace TinyRender;
|
||||
|
||||
struct DepthShader : public IShader
|
||||
{
|
||||
Model* m_model;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define TINY_RENDERER_H
|
||||
|
||||
#include "geometry.h"
|
||||
#include "model.h"
|
||||
#include "Bullet3Common/b3AlignedObjectArray.h"
|
||||
#include "Bullet3Common/b3Vector3.h"
|
||||
#include "LinearMath/btAlignedObjectArray.h"
|
||||
@@ -12,9 +13,9 @@
|
||||
struct TinyRenderObjectData
|
||||
{
|
||||
//Camera
|
||||
Matrix m_viewMatrix;
|
||||
Matrix m_projectionMatrix;
|
||||
Matrix m_viewportMatrix;
|
||||
TinyRender::Matrix m_viewMatrix;
|
||||
TinyRender::Matrix m_projectionMatrix;
|
||||
TinyRender::Matrix m_viewportMatrix;
|
||||
btVector3 m_localScaling;
|
||||
btVector3 m_lightDirWorld;
|
||||
btVector3 m_lightColor;
|
||||
@@ -24,8 +25,8 @@ struct TinyRenderObjectData
|
||||
float m_lightSpecularCoeff;
|
||||
|
||||
//Model (vertices, indices, textures, shader)
|
||||
Matrix m_modelMatrix;
|
||||
class Model* m_model;
|
||||
TinyRender::Matrix m_modelMatrix;
|
||||
TinyRender::Model* m_model;
|
||||
//class IShader* m_shader; todo(erwincoumans) expose the shader, for now we use a default shader
|
||||
|
||||
//Output
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "geometry.h"
|
||||
|
||||
namespace TinyRender
|
||||
{
|
||||
template <>
|
||||
template <>
|
||||
vec<3, int>::vec(const vec<3, float> &v) : x(int(v.x + .5f)), y(int(v.y + .5f)), z(int(v.z + .5f))
|
||||
@@ -20,3 +22,4 @@ template <>
|
||||
vec<2, float>::vec(const vec<2, int> &v) : x(v.x), y(v.y)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,8 @@
|
||||
#include <cassert>
|
||||
#include <stdlib.h>
|
||||
|
||||
namespace TinyRender
|
||||
{
|
||||
template <size_t DimCols, size_t DimRows, typename T>
|
||||
class mat;
|
||||
|
||||
@@ -318,4 +320,6 @@ typedef vec<3, float> Vec3f;
|
||||
typedef vec<3, int> Vec3i;
|
||||
typedef vec<4, float> Vec4f;
|
||||
typedef mat<4, 4, float> Matrix;
|
||||
}
|
||||
|
||||
#endif //__GEOMETRY_H__
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include "Bullet3Common/b3Logging.h"
|
||||
|
||||
namespace TinyRender
|
||||
{
|
||||
Model::Model(const char *filename) : verts_(), faces_(), norms_(), uv_(), diffusemap_(), normalmap_(), specularmap_()
|
||||
{
|
||||
std::ifstream in;
|
||||
@@ -202,3 +205,4 @@ Vec3f Model::normal(int iface, int nthvert)
|
||||
int idx = faces_[iface][nthvert][2];
|
||||
return norms_[idx].normalize();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include "geometry.h"
|
||||
#include "tgaimage.h"
|
||||
|
||||
namespace TinyRender
|
||||
{
|
||||
class Model
|
||||
{
|
||||
private:
|
||||
@@ -52,4 +54,6 @@ public:
|
||||
float specular(Vec2f uv);
|
||||
std::vector<int> face(int idx);
|
||||
};
|
||||
}
|
||||
|
||||
#endif //__MODEL_H__
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include "our_gl.h"
|
||||
#include "Bullet3Common/b3MinMax.h"
|
||||
|
||||
namespace TinyRender
|
||||
{
|
||||
IShader::~IShader() {}
|
||||
|
||||
Matrix viewport(int x, int y, int w, int h)
|
||||
@@ -205,3 +207,4 @@ void triangle(mat<4, 3, float> &clipc, IShader &shader, TGAImage &image, float *
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include "tgaimage.h"
|
||||
#include "geometry.h"
|
||||
|
||||
namespace TinyRender
|
||||
{
|
||||
Matrix viewport(int x, int y, int w, int h);
|
||||
Matrix projection(float coeff = 0.f); // coeff = -1/c
|
||||
Matrix lookat(Vec3f eye, Vec3f center, Vec3f up);
|
||||
@@ -20,5 +22,6 @@ void triangle(mat<4, 3, float> &pts, IShader &shader, TGAImage &image, float *zb
|
||||
void triangle(mat<4, 3, float> &pts, IShader &shader, TGAImage &image, float *zbuffer, int *segmentationMaskBuffer, const Matrix &viewPortMatrix, int objectIndex);
|
||||
void triangleClipped(mat<4, 3, float> &clippedPts, mat<4, 3, float> &pts, IShader &shader, TGAImage &image, float *zbuffer, const Matrix &viewPortMatrix);
|
||||
void triangleClipped(mat<4, 3, float> &clippedPts, mat<4, 3, float> &pts, IShader &shader, TGAImage &image, float *zbuffer, int *segmentationMaskBuffer, const Matrix &viewPortMatrix, int objectIndex);
|
||||
}
|
||||
|
||||
#endif //__OUR_GL_H__
|
||||
|
||||
Reference in New Issue
Block a user