fix build3/stringify.sh

fix some compile issues
This commit is contained in:
Erwin Coumans 2016-05-25 15:37:28 -07:00
parent bd1620eda8
commit 535ee33e3b
9 changed files with 193 additions and 97 deletions

View File

@ -51,18 +51,18 @@ eval '$mypremake --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/Raycast/kernels/rayCastKernels.cl" --headerfile="../src/Bullet3OpenCL/Raycast/kernels/rayCastKernels.h" --stringname="rayCastKernelCL" stringify'
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../btgui/OpenGLWindow/Shaders/instancingVS.glsl" --headerfile="../btgui/OpenGLWindow/Shaders/instancingVS.h" --stringname="instancingVertexShader" stringify'
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../btgui/OpenGLWindow/Shaders/instancingPS.glsl" --headerfile="../btgui/OpenGLWindow/Shaders/instancingPS.h" --stringname="instancingFragmentShader" stringify'
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../btgui/OpenGLWindow/Shaders/pointSpriteVS.glsl" --headerfile="../btgui/OpenGLWindow/Shaders/pointSpriteVS.h" --stringname="pointSpriteVertexShader" stringify'
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../btgui/OpenGLWindow/Shaders/pointSpritePS.glsl" --headerfile="../btgui/OpenGLWindow/Shaders/pointSpritePS.h" --stringname="pointSpriteFragmentShader" stringify'
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../examples/OpenGLWindow/Shaders/instancingVS.glsl" --headerfile="../examples/OpenGLWindow/Shaders/instancingVS.h" --stringname="instancingVertexShader" stringify'
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../examples/OpenGLWindow/Shaders/instancingPS.glsl" --headerfile="../examples/OpenGLWindow/Shaders/instancingPS.h" --stringname="instancingFragmentShader" stringify'
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../examples/OpenGLWindow/Shaders/pointSpriteVS.glsl" --headerfile="../examples/OpenGLWindow/Shaders/pointSpriteVS.h" --stringname="pointSpriteVertexShader" stringify'
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../examples/OpenGLWindow/Shaders/pointSpritePS.glsl" --headerfile="../examples/OpenGLWindow/Shaders/pointSpritePS.h" --stringname="pointSpriteFragmentShader" stringify'
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../btgui/OpenGLWindow/Shaders/createShadowMapInstancingPS.glsl" --headerfile="../btgui/OpenGLWindow/Shaders/createShadowMapInstancingPS.h" --stringname="createShadowMapInstancingFragmentShader" stringify'
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../btgui/OpenGLWindow/Shaders/createShadowMapInstancingVS.glsl" --headerfile="../btgui/OpenGLWindow/Shaders/createShadowMapInstancingVS.h" --stringname="createShadowMapInstancingVertexShader" stringify'
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../examples/OpenGLWindow/Shaders/createShadowMapInstancingPS.glsl" --headerfile="../examples/OpenGLWindow/Shaders/createShadowMapInstancingPS.h" --stringname="createShadowMapInstancingFragmentShader" stringify'
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../examples/OpenGLWindow/Shaders/createShadowMapInstancingVS.glsl" --headerfile="../examples/OpenGLWindow/Shaders/createShadowMapInstancingVS.h" --stringname="createShadowMapInstancingVertexShader" stringify'
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../btgui/OpenGLWindow/Shaders/useShadowMapInstancingPS.glsl" --headerfile="../btgui/OpenGLWindow/Shaders/useShadowMapInstancingPS.h" --stringname="useShadowMapInstancingFragmentShader" stringify'
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../btgui/OpenGLWindow/Shaders/useShadowMapInstancingVS.glsl" --headerfile="../btgui/OpenGLWindow/Shaders/useShadowMapInstancingVS.h" --stringname="useShadowMapInstancingVertexShader" stringify'
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../Demos3/GpuDemos/broadphase/pairsKernel.cl" --headerfile="../Demos3/GpuDemos/broadphase/pairsKernel.h" --stringname="pairsKernelsCL" stringify'
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../examples/OpenGLWindow/Shaders/useShadowMapInstancingPS.glsl" --headerfile="../examples/OpenGLWindow/Shaders/useShadowMapInstancingPS.h" --stringname="useShadowMapInstancingFragmentShader" stringify'
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../examples/OpenGLWindow/Shaders/useShadowMapInstancingVS.glsl" --headerfile="../examples/OpenGLWindow/Shaders/useShadowMapInstancingVS.h" --stringname="useShadowMapInstancingVertexShader" stringify'
eval '$mypremake --file=stringifyKernel.lua --kernelfile="../examples/OpenCL/broadphase/pairsKernel.cl" --headerfile="../examples/OpenCL/broadphase/pairsKernel.h" --stringname="pairsKernelsCL" stringify'

View File

@ -1,5 +1,5 @@
#ifndef B3_IMPORT_MESH_UTILITY_H
#define B3_IMPORT_MESH_UTILIY_H
#define B3_IMPORT_MESH_UTILITY_H
#include <string>

View File

@ -152,7 +152,6 @@ void InverseDynamicsExample::initPhysics()
switch (m_option)
{
case 0:
case BT_ID_LOAD_URDF:
{
@ -348,4 +347,4 @@ CommonExampleInterface* InverseDynamicsExampleCreateFunc(CommonExampleOptions
B3_STANDALONE_EXAMPLE(InverseDynamicsExampleCreateFunc)
B3_STANDALONE_EXAMPLE(InverseDynamicsExampleCreateFunc)

View File

@ -17,6 +17,70 @@
#include "../OpenGLWindow/GLInstanceGraphicsShape.h"
#include "../CommonInterfaces/CommonParameterInterface.h"
struct TinyRendererSetupInternalData
{
TGAImage m_rgbColorBuffer;
b3AlignedObjectArray<float> m_depthBuffer;
int m_width;
int m_height;
btAlignedObjectArray<btConvexShape*> m_shapePtr;
btAlignedObjectArray<btTransform> m_transforms;
btAlignedObjectArray<TinyRenderObjectData*> m_renderObjects;
btVoronoiSimplexSolver m_simplexSolver;
btScalar m_pitch;
btScalar m_roll;
btScalar m_yaw;
int m_textureHandle;
int m_animateRenderer;
TinyRendererSetupInternalData(int width, int height)
:m_roll(0),
m_pitch(0),
m_yaw(0),
m_width(width),
m_height(height),
m_rgbColorBuffer(width,height,TGAImage::RGB),
m_textureHandle(0),
m_animateRenderer(0)
{
m_depthBuffer.resize(m_width*m_height);
}
void updateTransforms()
{
int numObjects = m_shapePtr.size();
m_transforms.resize(numObjects);
for (int i=0;i<numObjects;i++)
{
m_transforms[i].setIdentity();
//btVector3 pos(0.f,-(2.5* numObjects * 0.5)+i*2.5f, 0.f);
btVector3 pos(0.f,+i*2.5f, 0.f);
m_transforms[i].setIdentity();
m_transforms[i].setOrigin( pos );
btQuaternion orn;
if (i < 2)
{
orn.setEuler(m_yaw,m_pitch,m_roll);
m_transforms[i].setRotation(orn);
}
}
if (m_animateRenderer)
{
m_pitch += 0.005f;
m_yaw += 0.01f;
}
}
};
struct TinyRendererSetup : public CommonExampleInterface
{
@ -24,6 +88,7 @@ struct TinyRendererSetup : public CommonExampleInterface
struct CommonGraphicsApp* m_app;
struct TinyRendererSetupInternalData* m_internalData;
bool m_useSoftware;
TinyRendererSetup(struct GUIHelperInterface* guiHelper);
@ -50,78 +115,29 @@ struct TinyRendererSetup : public CommonExampleInterface
{
}
void animateRenderer(int animateRendererIndex)
{
m_internalData->m_animateRenderer = animateRendererIndex;
}
void selectRenderer(int rendererIndex)
{
m_useSoftware = (rendererIndex==0);
}
};
struct TinyRendererSetupInternalData
{
TGAImage m_rgbColorBuffer;
b3AlignedObjectArray<float> m_depthBuffer;
int m_width;
int m_height;
btAlignedObjectArray<btConvexShape*> m_shapePtr;
btAlignedObjectArray<btTransform> m_transforms;
btAlignedObjectArray<TinyRenderObjectData*> m_renderObjects;
btVoronoiSimplexSolver m_simplexSolver;
btScalar m_pitch;
btScalar m_roll;
btScalar m_yaw;
int m_textureHandle;
TinyRendererSetupInternalData(int width, int height)
:m_roll(0),
m_pitch(0),
m_yaw(0),
m_width(width),
m_height(height),
m_rgbColorBuffer(width,height,TGAImage::RGB),
m_textureHandle(0)
{
m_depthBuffer.resize(m_width*m_height);
}
void updateTransforms()
{
int numObjects = m_shapePtr.size();
m_transforms.resize(numObjects);
for (int i=0;i<numObjects;i++)
{
m_transforms[i].setIdentity();
//btVector3 pos(0.f,-(2.5* numObjects * 0.5)+i*2.5f, 0.f);
btVector3 pos(0.f,+i*2.5f, 0.f);
m_transforms[i].setIdentity();
m_transforms[i].setOrigin( pos );
btQuaternion orn;
if (i < 2)
{
orn.setEuler(m_yaw,m_pitch,m_roll);
m_transforms[i].setRotation(orn);
}
}
m_pitch += 0.005f;
m_yaw += 0.01f;
}
};
TinyRendererSetup::TinyRendererSetup(struct GUIHelperInterface* gui)
{
m_useSoftware = false;
m_guiHelper = gui;
m_app = gui->getAppInterface();
m_internalData = new TinyRendererSetupInternalData(gui->getAppInterface()->m_window->getWidth(),gui->getAppInterface()->m_window->getHeight());
m_app->m_renderer->enableBlend(true);
const char* fileName = "textured_sphere_smooth.obj";//cube.obj";
const char* fileName = "teddy.obj";//cube.obj";//textured_sphere_smooth.obj";//cube.obj";
{
@ -185,8 +201,28 @@ TinyRendererSetup::~TinyRendererSetup()
delete m_internalData;
}
const char* itemsanimate[] = {"Fixed", "Rotate"};
void TinyRendererComboCallbackAnimate(int combobox, const char* item, void* userPointer)
{
TinyRendererSetup* cl = (TinyRendererSetup*) userPointer;
b3Assert(cl);
int index=-1;
int numItems = sizeof(itemsanimate)/sizeof(char*);
for (int i=0;i<numItems;i++)
{
if (!strcmp(item,itemsanimate[i]))
{
index = i;
}
}
cl->animateRenderer(index);
}
const char* items[] = {"Software", "OpenGL"};
void TinyRendererComboCallback(int combobox, const char* item, void* userPointer)
{
TinyRendererSetup* cl = (TinyRendererSetup*) userPointer;
@ -204,7 +240,6 @@ void TinyRendererComboCallback(int combobox, const char* item, void* userPointer
}
void TinyRendererSetup::initPhysics()
{
//request a visual bitma/texture we can render to
@ -215,6 +250,7 @@ void TinyRendererSetup::initPhysics()
m_internalData->m_textureHandle = render->registerTexture(m_internalData->m_rgbColorBuffer.buffer(),m_internalData->m_width,m_internalData->m_height);
{
ComboBoxParams comboParams;
comboParams.m_userPointer = this;
comboParams.m_numItems=sizeof(items)/sizeof(char*);
@ -222,7 +258,18 @@ void TinyRendererSetup::initPhysics()
comboParams.m_items=items;
comboParams.m_callback =TinyRendererComboCallback;
m_guiHelper->getParameterInterface()->registerComboBox( comboParams);
}
{
ComboBoxParams comboParams;
comboParams.m_userPointer = this;
comboParams.m_numItems=sizeof(itemsanimate)/sizeof(char*);
comboParams.m_startItem = 0;
comboParams.m_items=itemsanimate;
comboParams.m_callback =TinyRendererComboCallbackAnimate;
m_guiHelper->getParameterInterface()->registerComboBox( comboParams);
}
}

View File

@ -19,7 +19,8 @@ struct Shader : public IShader {
Model* m_model;
Vec3f m_light_dir_local;
Matrix& m_modelView;
Matrix& m_modelMat;
Matrix& m_modelView1;
Matrix& m_projectionMatrix;
mat<2,3,float> varying_uv; // triangle uv coordinates, written by the vertex shader, read by the fragment shader
@ -27,11 +28,12 @@ struct Shader : public IShader {
mat<3,3,float> varying_nrm; // normal per vertex to be interpolated by FS
mat<3,3,float> ndc_tri; // triangle in normalized device coordinates
Shader(Model* model, Vec3f light_dir_local, Matrix& modelView, Matrix& projectionMatrix)
Shader(Model* model, Vec3f light_dir_local, Matrix& modelView, Matrix& projectionMatrix, Matrix& modelMat)
:m_model(model),
m_light_dir_local(light_dir_local),
m_modelView(modelView),
m_projectionMatrix(projectionMatrix)
m_modelView1(modelView),
m_projectionMatrix(projectionMatrix),
m_modelMat(modelMat)
{
}
@ -42,8 +44,9 @@ struct Shader : public IShader {
//printf("uv = %f,%f\n", uv.x,uv.y);
varying_uv.set_col(nthvert, uv);
varying_nrm.set_col(nthvert, proj<3>((m_projectionMatrix*m_modelView).invert_transpose()*embed<4>(m_model->normal(iface, nthvert), 0.f)));
Vec4f gl_Vertex = m_projectionMatrix*m_modelView*embed<4>(m_model->vert(iface, nthvert));
//varying_nrm.set_col(nthvert, proj<3>((m_projectionMatrix*m_modelView).invert_transpose()*embed<4>(m_model->normal(iface, nthvert), 0.f)));
varying_nrm.set_col(nthvert, proj<3>((m_modelMat).invert_transpose()*embed<4>(m_model->normal(iface, nthvert), 0.f)));
Vec4f gl_Vertex = m_projectionMatrix*m_modelView1*embed<4>(m_model->vert(iface, nthvert));
varying_tri.set_col(nthvert, gl_Vertex);
ndc_tri.set_col(nthvert, proj<3>(gl_Vertex/gl_Vertex[3]));
return gl_Vertex;
@ -69,9 +72,9 @@ struct Shader : public IShader {
B.set_col(2, bn);
Vec3f n = (B*m_model->normal(uv)).normalize();
float diff = 1;//b3Min(b3Max(0.f, n*0.3f),1.f);
//float diff = b3Min(b3Max(0.f, n*m_light_dir_local+0.3f),1.f);
//float diff = 1;//b3Min(b3Max(0.f, n*0.3f),1.f);
float diff = b3Min(b3Max(0.f, bn*light_dir_world+0.3f),1.f);
//float diff = b3Max(0.f, n*m_light_dir_local);
color = m_model->diffuse(uv)*diff;
@ -256,7 +259,7 @@ void TinyRenderer::renderObject(TinyRenderObjectData& renderData)
{
Matrix modelViewMatrix = renderData.m_viewMatrix*renderData.m_modelMatrix;
Shader shader(model, light_dir_local, modelViewMatrix, renderData.m_projectionMatrix);
Shader shader(model, light_dir_local, modelViewMatrix, renderData.m_projectionMatrix,renderData.m_modelMatrix);
for (int i=0; i<model->nfaces(); i++) {

View File

@ -1,7 +1,6 @@
#include "../SharedMemory/SharedMemoryInProcessPhysicsC_API.h"
#include "../SharedMemory/PhysicsClientC_API.h"
#include "../SharedMemory/PhysicsDirectC_API.h"
#include "../SharedMemory/SharedMemoryInProcessPhysicsC_API.h"
#ifdef __APPLE__

View File

@ -404,17 +404,33 @@ static const char* mprKernelsCL= \
" int m_compoundBvhIndex;\n"
" };\n"
" int m_shapeType;\n"
" int m_shapeIndex;\n"
" union\n"
" {\n"
" int m_shapeIndex;\n"
" float m_height;\n"
" };\n"
"};\n"
"typedef struct b3GpuChildShape b3GpuChildShape_t;\n"
"struct b3GpuChildShape\n"
"{\n"
" b3Float4 m_childPosition;\n"
" b3Quat m_childOrientation;\n"
" int m_shapeIndex;\n"
" int m_unused0;\n"
" int m_unused1;\n"
" int m_unused2;\n"
" union\n"
" {\n"
" int m_shapeIndex;//used for SHAPE_COMPOUND_OF_CONVEX_HULLS\n"
" int m_capsuleAxis;\n"
" };\n"
" union \n"
" {\n"
" float m_radius;//used for childshape of SHAPE_COMPOUND_OF_SPHERES or SHAPE_COMPOUND_OF_CAPSULES\n"
" int m_numChildShapes;//used for compound shape\n"
" };\n"
" union \n"
" {\n"
" float m_height;//used for childshape of SHAPE_COMPOUND_OF_CAPSULES\n"
" int m_collidableShapeIndex;\n"
" };\n"
" int m_shapeType;\n"
"};\n"
"struct b3CompoundOverlappingPair\n"
"{\n"

View File

@ -281,17 +281,33 @@ static const char* satClipKernelsCL= \
" int m_compoundBvhIndex;\n"
" };\n"
" int m_shapeType;\n"
" int m_shapeIndex;\n"
" union\n"
" {\n"
" int m_shapeIndex;\n"
" float m_height;\n"
" };\n"
"};\n"
"typedef struct b3GpuChildShape b3GpuChildShape_t;\n"
"struct b3GpuChildShape\n"
"{\n"
" b3Float4 m_childPosition;\n"
" b3Quat m_childOrientation;\n"
" int m_shapeIndex;\n"
" int m_unused0;\n"
" int m_unused1;\n"
" int m_unused2;\n"
" union\n"
" {\n"
" int m_shapeIndex;//used for SHAPE_COMPOUND_OF_CONVEX_HULLS\n"
" int m_capsuleAxis;\n"
" };\n"
" union \n"
" {\n"
" float m_radius;//used for childshape of SHAPE_COMPOUND_OF_SPHERES or SHAPE_COMPOUND_OF_CAPSULES\n"
" int m_numChildShapes;//used for compound shape\n"
" };\n"
" union \n"
" {\n"
" float m_height;//used for childshape of SHAPE_COMPOUND_OF_CAPSULES\n"
" int m_collidableShapeIndex;\n"
" };\n"
" int m_shapeType;\n"
"};\n"
"struct b3CompoundOverlappingPair\n"
"{\n"

View File

@ -363,17 +363,33 @@ static const char* updateAabbsKernelCL= \
" int m_compoundBvhIndex;\n"
" };\n"
" int m_shapeType;\n"
" int m_shapeIndex;\n"
" union\n"
" {\n"
" int m_shapeIndex;\n"
" float m_height;\n"
" };\n"
"};\n"
"typedef struct b3GpuChildShape b3GpuChildShape_t;\n"
"struct b3GpuChildShape\n"
"{\n"
" b3Float4 m_childPosition;\n"
" b3Quat m_childOrientation;\n"
" int m_shapeIndex;\n"
" int m_unused0;\n"
" int m_unused1;\n"
" int m_unused2;\n"
" union\n"
" {\n"
" int m_shapeIndex;//used for SHAPE_COMPOUND_OF_CONVEX_HULLS\n"
" int m_capsuleAxis;\n"
" };\n"
" union \n"
" {\n"
" float m_radius;//used for childshape of SHAPE_COMPOUND_OF_SPHERES or SHAPE_COMPOUND_OF_CAPSULES\n"
" int m_numChildShapes;//used for compound shape\n"
" };\n"
" union \n"
" {\n"
" float m_height;//used for childshape of SHAPE_COMPOUND_OF_CAPSULES\n"
" int m_collidableShapeIndex;\n"
" };\n"
" int m_shapeType;\n"
"};\n"
"struct b3CompoundOverlappingPair\n"
"{\n"