Code-style consistency improvement:
Apply clang-format-all.sh using the _clang-format file through all the cpp/.h files. make sure not to apply it to certain serialization structures, since some parser expects the * as part of the name, instead of type. This commit contains no other changes aside from adding and applying clang-format-all.sh
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#include "ImportObjExample.h"
|
||||
#include <vector>
|
||||
#include "../OpenGLWindow/GLInstancingRenderer.h"
|
||||
#include"Wavefront/tiny_obj_loader.h"
|
||||
#include "Wavefront/tiny_obj_loader.h"
|
||||
#include "../OpenGLWindow/GLInstanceGraphicsShape.h"
|
||||
#include "btBulletDynamicsCommon.h"
|
||||
#include "../OpenGLWindow/SimpleOpenGL3App.h"
|
||||
@@ -16,14 +16,12 @@
|
||||
|
||||
class ImportObjSetup : public CommonRigidBodyBase
|
||||
{
|
||||
std::string m_fileName;
|
||||
|
||||
std::string m_fileName;
|
||||
|
||||
|
||||
public:
|
||||
ImportObjSetup(struct GUIHelperInterface* helper, const char* fileName);
|
||||
virtual ~ImportObjSetup();
|
||||
|
||||
ImportObjSetup(struct GUIHelperInterface* helper, const char* fileName);
|
||||
virtual ~ImportObjSetup();
|
||||
|
||||
virtual void initPhysics();
|
||||
|
||||
virtual void resetCamera()
|
||||
@@ -31,48 +29,45 @@ public:
|
||||
float dist = 18;
|
||||
float pitch = -46;
|
||||
float yaw = 120;
|
||||
float targetPos[3]={-2,-2,-2};
|
||||
m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
|
||||
float targetPos[3] = {-2, -2, -2};
|
||||
m_guiHelper->resetCamera(dist, yaw, pitch, targetPos[0], targetPos[1], targetPos[2]);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
ImportObjSetup::ImportObjSetup(struct GUIHelperInterface* helper, const char* fileName)
|
||||
:CommonRigidBodyBase(helper)
|
||||
: CommonRigidBodyBase(helper)
|
||||
{
|
||||
if (fileName)
|
||||
{
|
||||
m_fileName = fileName;
|
||||
} else
|
||||
{
|
||||
m_fileName = "cube.obj";//"sponza_closed.obj";//sphere8.obj";
|
||||
}
|
||||
if (fileName)
|
||||
{
|
||||
m_fileName = fileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_fileName = "cube.obj"; //"sponza_closed.obj";//sphere8.obj";
|
||||
}
|
||||
}
|
||||
|
||||
ImportObjSetup::~ImportObjSetup()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int loadAndRegisterMeshFromFile2(const std::string& fileName, CommonRenderInterface* renderer)
|
||||
{
|
||||
int shapeId = -1;
|
||||
|
||||
|
||||
b3ImportMeshData meshData;
|
||||
if (b3ImportMeshUtility::loadAndRegisterMeshFromFileInternal(fileName, meshData))
|
||||
{
|
||||
int textureIndex = -1;
|
||||
|
||||
|
||||
if (meshData.m_textureImage1)
|
||||
{
|
||||
textureIndex = renderer->registerTexture(meshData.m_textureImage1,meshData.m_textureWidth,meshData.m_textureHeight);
|
||||
textureIndex = renderer->registerTexture(meshData.m_textureImage1, meshData.m_textureWidth, meshData.m_textureHeight);
|
||||
}
|
||||
|
||||
shapeId = renderer->registerShape(&meshData.m_gfxShape->m_vertices->at(0).xyzw[0],
|
||||
meshData.m_gfxShape->m_numvertices,
|
||||
&meshData.m_gfxShape->m_indices->at(0),
|
||||
|
||||
shapeId = renderer->registerShape(&meshData.m_gfxShape->m_vertices->at(0).xyzw[0],
|
||||
meshData.m_gfxShape->m_numvertices,
|
||||
&meshData.m_gfxShape->m_indices->at(0),
|
||||
meshData.m_gfxShape->m_numIndices,
|
||||
B3_GL_TRIANGLES,
|
||||
textureIndex);
|
||||
@@ -85,8 +80,6 @@ int loadAndRegisterMeshFromFile2(const std::string& fileName, CommonRenderInterf
|
||||
return shapeId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ImportObjSetup::initPhysics()
|
||||
{
|
||||
m_guiHelper->setUpAxis(2);
|
||||
@@ -94,26 +87,24 @@ void ImportObjSetup::initPhysics()
|
||||
m_guiHelper->createPhysicsDebugDrawer(m_dynamicsWorld);
|
||||
m_dynamicsWorld->getDebugDrawer()->setDebugMode(btIDebugDraw::DBG_DrawWireframe);
|
||||
|
||||
|
||||
btTransform trans;
|
||||
trans.setIdentity();
|
||||
trans.setRotation(btQuaternion(btVector3(1,0,0),SIMD_HALF_PI));
|
||||
trans.setIdentity();
|
||||
trans.setRotation(btQuaternion(btVector3(1, 0, 0), SIMD_HALF_PI));
|
||||
btVector3 position = trans.getOrigin();
|
||||
btQuaternion orn = trans.getRotation();
|
||||
|
||||
btVector3 scaling(1,1,1);
|
||||
btVector3 color(1,1,1);
|
||||
|
||||
int shapeId = loadAndRegisterMeshFromFile2(m_fileName, m_guiHelper->getRenderInterface());
|
||||
if (shapeId>=0)
|
||||
{
|
||||
//int id =
|
||||
m_guiHelper->getRenderInterface()->registerGraphicsInstance(shapeId,position,orn,color,scaling);
|
||||
}
|
||||
|
||||
btVector3 scaling(1, 1, 1);
|
||||
btVector3 color(1, 1, 1);
|
||||
|
||||
int shapeId = loadAndRegisterMeshFromFile2(m_fileName, m_guiHelper->getRenderInterface());
|
||||
if (shapeId >= 0)
|
||||
{
|
||||
//int id =
|
||||
m_guiHelper->getRenderInterface()->registerGraphicsInstance(shapeId, position, orn, color, scaling);
|
||||
}
|
||||
}
|
||||
|
||||
CommonExampleInterface* ImportObjCreateFunc(struct CommonExampleOptions& options)
|
||||
{
|
||||
return new ImportObjSetup(options.m_guiHelper, options.m_fileName);
|
||||
}
|
||||
CommonExampleInterface* ImportObjCreateFunc(struct CommonExampleOptions& options)
|
||||
{
|
||||
return new ImportObjSetup(options.m_guiHelper, options.m_fileName);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user