Preliminary working version of TinyRenderer for standalone demos,
it works without OpenGL dependency now, so it runs in the cloud :-) Add scaling support for TinyRenderer, remove some un-used normal mapping in TinyRenderer shader, expose light_dir_world, remove accidental hard-coded path in tga write_tga_file, Fix InverseDynamicsExampleCreateFunc, enum has to start at 0
This commit is contained in:
@@ -42,7 +42,7 @@ struct RigidBodyFromObjExample : public CommonRigidBodyBase
|
||||
virtual void renderScene();
|
||||
void resetCamera()
|
||||
{
|
||||
float dist = 41;
|
||||
float dist = 11;
|
||||
float pitch = 52;
|
||||
float yaw = 35;
|
||||
float targetPos[3]={0,0.46,0};
|
||||
@@ -74,7 +74,7 @@ void RigidBodyFromObjExample::initPhysics()
|
||||
}
|
||||
|
||||
//load our obj mesh
|
||||
const char* fileName = "teddy.obj";//sphere8.obj";//sponza_closed.obj";//sphere8.obj";
|
||||
const char* fileName = "textured_sphere_smooth.obj";//teddy.obj";//sphere8.obj";//sponza_closed.obj";//sphere8.obj";
|
||||
char relativeFileName[1024];
|
||||
if (b3ResourcePath::findResourcePath(fileName, relativeFileName, 1024))
|
||||
{
|
||||
@@ -88,7 +88,8 @@ void RigidBodyFromObjExample::initPhysics()
|
||||
const GLInstanceVertex& v = glmesh->m_vertices->at(0);
|
||||
btConvexHullShape* shape = new btConvexHullShape((const btScalar*)(&(v.xyzw[0])), glmesh->m_numvertices, sizeof(GLInstanceVertex));
|
||||
|
||||
shape->setLocalScaling(btVector3(0.1,0.1,0.1));
|
||||
btVector3 localScaling(2,2,2);//0.1,0.1,0.1);
|
||||
shape->setLocalScaling(localScaling);
|
||||
|
||||
if (m_options & OptimizeConvexObj)
|
||||
{
|
||||
@@ -114,25 +115,24 @@ void RigidBodyFromObjExample::initPhysics()
|
||||
if (isDynamic)
|
||||
shape->calculateLocalInertia(mass,localInertia);
|
||||
|
||||
btVector3 position(0,20,0);
|
||||
btVector3 position(0,3,0);
|
||||
startTransform.setOrigin(position);
|
||||
btRigidBody* body = createRigidBody(mass,startTransform,shape);
|
||||
|
||||
btVector3 color(1,1,1);
|
||||
btVector3 scaling(0.1,0.1,0.1);
|
||||
|
||||
bool useConvexHullForRendering = ((m_options & ObjUseConvexHullForRendering)!=0);
|
||||
|
||||
|
||||
if (!useConvexHullForRendering)
|
||||
{
|
||||
int shapeId = m_guiHelper->getRenderInterface()->registerShape(&glmesh->m_vertices->at(0).xyzw[0],
|
||||
glmesh->m_numvertices,
|
||||
&glmesh->m_indices->at(0),
|
||||
glmesh->m_numIndices,
|
||||
B3_GL_TRIANGLES,-1);
|
||||
shape->setUserIndex(shapeId);
|
||||
int renderInstance = m_guiHelper->getRenderInterface()->registerGraphicsInstance(shapeId,position,startTransform.getRotation(),color,scaling);
|
||||
body->setUserIndex(renderInstance);
|
||||
int shapeId = m_guiHelper->registerGraphicsShape(&glmesh->m_vertices->at(0).xyzw[0],
|
||||
glmesh->m_numvertices,
|
||||
&glmesh->m_indices->at(0),
|
||||
glmesh->m_numIndices);
|
||||
shape->setUserIndex(shapeId);
|
||||
int renderInstance = m_guiHelper->registerGraphicsInstance(shapeId,position,startTransform.getRotation(),color,localScaling);
|
||||
body->setUserIndex(renderInstance);
|
||||
}
|
||||
|
||||
m_guiHelper->autogenerateGraphicsObjects(m_dynamicsWorld);
|
||||
@@ -155,5 +155,5 @@ CommonExampleInterface* ET_RigidBodyFromObjCreateFunc(CommonExampleOptions& o
|
||||
return new RigidBodyFromObjExample(options.m_guiHelper,options.m_option);
|
||||
}
|
||||
|
||||
|
||||
B3_STANDALONE_EXAMPLE(ET_RigidBodyFromObjCreateFunc)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user