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:
erwin coumans
2016-05-26 17:36:01 -07:00
parent 68545fb71a
commit 0d50d8c73b
12 changed files with 781 additions and 80 deletions

View File

@@ -150,10 +150,27 @@ public:
ATTRIBUTE_ALIGNED16(float modelMat[16]);
ATTRIBUTE_ALIGNED16(float viewMat[16]);
ATTRIBUTE_ALIGNED16(float projMat[16]);
CommonRenderInterface* render = getRenderInterface();
render->getActiveCamera()->getCameraProjectionMatrix(projMat);
render->getActiveCamera()->getCameraViewMatrix(viewMat);
btVector3 lightDirWorld(-5,200,-40);
switch (1)//app->getUpAxis())
{
case 1:
lightDirWorld = btVector3(-50.f,100,30);
break;
case 2:
lightDirWorld = btVector3(-50.f,30,100);
break;
default:{}
};
lightDirWorld.normalize();
for (int i=0;i<rbWorld->getNumCollisionObjects();i++)
{
@@ -173,21 +190,25 @@ public:
if (sptr)
{
renderObj = *sptr;
}
}
//sync the object transform
const btTransform& tr = colObj->getWorldTransform();
tr.getOpenGLMatrix(modelMat);
//sync the object transform
const btTransform& tr = colObj->getWorldTransform();
tr.getOpenGLMatrix(modelMat);
for (int i=0;i<4;i++)
{
for (int j=0;j<4;j++)
{
renderObj->m_modelMatrix[i][j] = modelMat[i+4*j];
renderObj->m_viewMatrix[i][j] = viewMat[i+4*j];
for (int i=0;i<4;i++)
{
for (int j=0;j<4;j++)
{
renderObj->m_projectionMatrix[i][j] = projMat[i+4*j];
renderObj->m_modelMatrix[i][j] = modelMat[i+4*j];
renderObj->m_viewMatrix[i][j] = viewMat[i+4*j];
renderObj->m_localScaling = colObj->getCollisionShape()->getLocalScaling();
renderObj->m_lightDirWorld = lightDirWorld;
}
}
TinyRenderer::renderObject(*renderObj);
}
}
TinyRenderer::renderObject(*renderObj);
}
}
@@ -210,10 +231,12 @@ public:
static int counter=0;
counter++;
if (counter>10)
if ((counter&7)==0)
{
counter=0;
getFrameBuffer().write_tga_file("/Users/erwincoumans/develop/bullet3/framebuf.tga",true);
char filename[1024];
sprintf(filename,"framebuf%d.tga",counter);
getFrameBuffer().write_tga_file(filename,true);
}
float color[4] = {1,1,1,1};
m_primRenderer->drawTexturedRect(0,0,m_swWidth, m_swHeight,color,0,0,1,1,true);