diff --git a/build3/stringify.sh b/build3/stringify.sh index feb319cdf..b5112fce2 100755 --- a/build3/stringify.sh +++ b/build3/stringify.sh @@ -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' diff --git a/examples/Importers/ImportMeshUtility/b3ImportMeshUtility.h b/examples/Importers/ImportMeshUtility/b3ImportMeshUtility.h index 93b445cde..96c061eaf 100644 --- a/examples/Importers/ImportMeshUtility/b3ImportMeshUtility.h +++ b/examples/Importers/ImportMeshUtility/b3ImportMeshUtility.h @@ -1,5 +1,5 @@ #ifndef B3_IMPORT_MESH_UTILITY_H -#define B3_IMPORT_MESH_UTILIY_H +#define B3_IMPORT_MESH_UTILITY_H #include diff --git a/examples/InverseDynamics/InverseDynamicsExample.cpp b/examples/InverseDynamics/InverseDynamicsExample.cpp index f80edd9b4..0de9ef4c3 100644 --- a/examples/InverseDynamics/InverseDynamicsExample.cpp +++ b/examples/InverseDynamics/InverseDynamicsExample.cpp @@ -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) \ No newline at end of file +B3_STANDALONE_EXAMPLE(InverseDynamicsExampleCreateFunc) diff --git a/examples/RenderingExamples/TinyRendererSetup.cpp b/examples/RenderingExamples/TinyRendererSetup.cpp index b638b4a3b..64b106d93 100644 --- a/examples/RenderingExamples/TinyRendererSetup.cpp +++ b/examples/RenderingExamples/TinyRendererSetup.cpp @@ -17,6 +17,70 @@ #include "../OpenGLWindow/GLInstanceGraphicsShape.h" #include "../CommonInterfaces/CommonParameterInterface.h" + +struct TinyRendererSetupInternalData +{ + + TGAImage m_rgbColorBuffer; + b3AlignedObjectArray m_depthBuffer; + + + int m_width; + int m_height; + + btAlignedObjectArray m_shapePtr; + btAlignedObjectArray m_transforms; + btAlignedObjectArray 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;im_animateRenderer = animateRendererIndex; + } + + void selectRenderer(int rendererIndex) { m_useSoftware = (rendererIndex==0); } }; -struct TinyRendererSetupInternalData -{ - - TGAImage m_rgbColorBuffer; - b3AlignedObjectArray m_depthBuffer; - - - int m_width; - int m_height; - - btAlignedObjectArray m_shapePtr; - btAlignedObjectArray m_transforms; - btAlignedObjectArray 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;igetAppInterface(); 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;ianimateRenderer(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); + } } diff --git a/examples/TinyRenderer/TinyRenderer.cpp b/examples/TinyRenderer/TinyRenderer.cpp index 251f91ced..38fff703d 100644 --- a/examples/TinyRenderer/TinyRenderer.cpp +++ b/examples/TinyRenderer/TinyRenderer.cpp @@ -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; infaces(); i++) { diff --git a/examples/pybullet/pybullet.c b/examples/pybullet/pybullet.c index e61eecfcf..fc19f31a3 100644 --- a/examples/pybullet/pybullet.c +++ b/examples/pybullet/pybullet.c @@ -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__ diff --git a/src/Bullet3OpenCL/NarrowphaseCollision/kernels/mprKernels.h b/src/Bullet3OpenCL/NarrowphaseCollision/kernels/mprKernels.h index 7ed4b382c..3704a8914 100644 --- a/src/Bullet3OpenCL/NarrowphaseCollision/kernels/mprKernels.h +++ b/src/Bullet3OpenCL/NarrowphaseCollision/kernels/mprKernels.h @@ -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" diff --git a/src/Bullet3OpenCL/NarrowphaseCollision/kernels/satClipHullContacts.h b/src/Bullet3OpenCL/NarrowphaseCollision/kernels/satClipHullContacts.h index f0ecfc785..f2acee16d 100644 --- a/src/Bullet3OpenCL/NarrowphaseCollision/kernels/satClipHullContacts.h +++ b/src/Bullet3OpenCL/NarrowphaseCollision/kernels/satClipHullContacts.h @@ -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" diff --git a/src/Bullet3OpenCL/RigidBody/kernels/updateAabbsKernel.h b/src/Bullet3OpenCL/RigidBody/kernels/updateAabbsKernel.h index d0b4ac9ba..d70e74017 100644 --- a/src/Bullet3OpenCL/RigidBody/kernels/updateAabbsKernel.h +++ b/src/Bullet3OpenCL/RigidBody/kernels/updateAabbsKernel.h @@ -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"