enable URDF loading throught the 'File/Open' menu
set a default camera targets for each demo. note that it is only reset when switching to a different demo, so you can restart at your chosen location. no OpenCL pairbench drawing in OpenGL2 (there is no VBO available etc)
This commit is contained in:
@@ -64,6 +64,14 @@ class BspDemo : public CommonRigidBodyBase
|
||||
|
||||
void initPhysics(const char* bspfilename);
|
||||
|
||||
virtual void resetCamera()
|
||||
{
|
||||
float dist = 43;
|
||||
float pitch = -175;
|
||||
float yaw = 12;
|
||||
float targetPos[3]={4,-25,-6};
|
||||
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
@@ -277,9 +285,9 @@ char* makeExeToBspFilename(const char* lpCmdLine)
|
||||
}
|
||||
|
||||
|
||||
struct CommonExampleInterface* ImportBspCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option)
|
||||
struct CommonExampleInterface* ImportBspCreateFunc(struct CommonExampleOptions& options)
|
||||
{
|
||||
BspDemo* demo = new BspDemo(helper);
|
||||
BspDemo* demo = new BspDemo(options.m_guiHelper);
|
||||
|
||||
demo->initPhysics("BspDemo.bsp");
|
||||
return demo;
|
||||
|
||||
@@ -15,7 +15,7 @@ subject to the following restrictions:
|
||||
#ifndef BSP_DEMO_H
|
||||
#define BSP_DEMO_H
|
||||
|
||||
class CommonExampleInterface* ImportBspCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option);
|
||||
class CommonExampleInterface* ImportBspCreateFunc(struct CommonExampleOptions& options);
|
||||
|
||||
|
||||
#endif //BSP_DEMO_H
|
||||
|
||||
@@ -12,6 +12,16 @@ public:
|
||||
|
||||
virtual void initPhysics();
|
||||
virtual void stepSimulation(float deltaTime);
|
||||
|
||||
virtual void resetCamera()
|
||||
{
|
||||
float dist = 9.5;
|
||||
float pitch = -2.8;
|
||||
float yaw = 20;
|
||||
float targetPos[3]={-0.2,-1.4,3.5};
|
||||
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -89,7 +99,7 @@ void SerializeSetup::stepSimulation(float deltaTime)
|
||||
CommonRigidBodyBase::stepSimulation(deltaTime);
|
||||
}
|
||||
|
||||
class CommonExampleInterface* SerializeBulletCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option)
|
||||
class CommonExampleInterface* SerializeBulletCreateFunc(struct CommonExampleOptions& options)
|
||||
{
|
||||
return new SerializeSetup(helper);
|
||||
return new SerializeSetup(options.m_guiHelper);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef SERIALIZE_SETUP_H
|
||||
#define SERIALIZE_SETUP_H
|
||||
|
||||
class CommonExampleInterface* SerializeBulletCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option);
|
||||
class CommonExampleInterface* SerializeBulletCreateFunc(struct CommonExampleOptions& options);
|
||||
|
||||
|
||||
#endif //SERIALIZE_SETUP_H
|
||||
|
||||
@@ -37,6 +37,15 @@ public:
|
||||
virtual ~ImportColladaSetup();
|
||||
|
||||
virtual void initPhysics();
|
||||
virtual void resetCamera()
|
||||
{
|
||||
float dist = 16;
|
||||
float pitch = -140;
|
||||
float yaw = 28;
|
||||
float targetPos[3]={-4,-3,-3};
|
||||
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
ImportColladaSetup::ImportColladaSetup(struct GUIHelperInterface* helper)
|
||||
@@ -197,7 +206,7 @@ void ImportColladaSetup::initPhysics()
|
||||
|
||||
}
|
||||
|
||||
class CommonExampleInterface* ImportColladaCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option)
|
||||
class CommonExampleInterface* ImportColladaCreateFunc(struct CommonExampleOptions& options)
|
||||
{
|
||||
return new ImportColladaSetup(helper);
|
||||
return new ImportColladaSetup(options.m_guiHelper);
|
||||
}
|
||||
@@ -19,7 +19,7 @@ subject to the following restrictions:
|
||||
#ifndef IMPORT_COLLADA_SETUP_H
|
||||
#define IMPORT_COLLADA_SETUP_H
|
||||
|
||||
class CommonExampleInterface* ImportColladaCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option);
|
||||
class CommonExampleInterface* ImportColladaCreateFunc(struct CommonExampleOptions& options);
|
||||
|
||||
|
||||
#endif //IMPORT_COLLADA_SETUP_H
|
||||
|
||||
@@ -19,6 +19,16 @@ public:
|
||||
virtual ~ImportObjSetup();
|
||||
|
||||
virtual void initPhysics();
|
||||
|
||||
virtual void resetCamera()
|
||||
{
|
||||
float dist = 50;
|
||||
float pitch = 61;
|
||||
float yaw = 18;
|
||||
float targetPos[3]={-15,-15,47};
|
||||
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
ImportObjSetup::ImportObjSetup(struct GUIHelperInterface* helper)
|
||||
@@ -99,7 +109,7 @@ void ImportObjSetup::initPhysics()
|
||||
}
|
||||
}
|
||||
|
||||
CommonExampleInterface* ImportObjCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option)
|
||||
CommonExampleInterface* ImportObjCreateFunc(struct CommonExampleOptions& options)
|
||||
{
|
||||
return new ImportObjSetup(helper);
|
||||
return new ImportObjSetup(options.m_guiHelper);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef IMPORT_OBJ_EXAMPLE_H
|
||||
#define IMPORT_OBJ_EXAMPLE_H
|
||||
|
||||
class CommonExampleInterface* ImportObjCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option);
|
||||
class CommonExampleInterface* ImportObjCreateFunc(struct CommonExampleOptions& options);
|
||||
|
||||
|
||||
#endif //IMPORT_OBJ_EXAMPLE_H
|
||||
|
||||
@@ -18,6 +18,15 @@ public:
|
||||
virtual ~ImportSTLSetup();
|
||||
|
||||
virtual void initPhysics();
|
||||
virtual void resetCamera()
|
||||
{
|
||||
float dist = 3.5;
|
||||
float pitch = -136;
|
||||
float yaw = 28;
|
||||
float targetPos[3]={0.47,0,-0.64};
|
||||
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -92,7 +101,7 @@ void ImportSTLSetup::initPhysics()
|
||||
}
|
||||
}
|
||||
|
||||
class CommonExampleInterface* ImportSTLCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option)
|
||||
class CommonExampleInterface* ImportSTLCreateFunc(struct CommonExampleOptions& options)
|
||||
{
|
||||
return new ImportSTLSetup(helper);
|
||||
return new ImportSTLSetup(options.m_guiHelper);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#ifndef IMPORT_STL_SETUP_H
|
||||
#define IMPORT_STL_SETUP_H
|
||||
|
||||
class CommonExampleInterface* ImportSTLCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option);
|
||||
class CommonExampleInterface* ImportSTLCreateFunc(struct CommonExampleOptions& options);
|
||||
|
||||
#endif //IMPORT_OBJ_SETUP_H
|
||||
|
||||
@@ -34,13 +34,22 @@ class ImportUrdfSetup : public CommonMultiBodyBase
|
||||
bool m_useMultiBody;
|
||||
|
||||
public:
|
||||
ImportUrdfSetup(struct GUIHelperInterface* helper, int option);
|
||||
ImportUrdfSetup(struct GUIHelperInterface* helper, int option, const char* fileName);
|
||||
virtual ~ImportUrdfSetup();
|
||||
|
||||
virtual void initPhysics();
|
||||
virtual void stepSimulation(float deltaTime);
|
||||
|
||||
void setFileName(const char* urdfFileName);
|
||||
|
||||
virtual void resetCamera()
|
||||
{
|
||||
float dist = 3.5;
|
||||
float pitch = -136;
|
||||
float yaw = 28;
|
||||
float targetPos[3]={0.47,0,-0.64};
|
||||
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -62,9 +71,11 @@ struct ImportUrdfInternalData
|
||||
};
|
||||
|
||||
|
||||
ImportUrdfSetup::ImportUrdfSetup(struct GUIHelperInterface* helper, int option)
|
||||
ImportUrdfSetup::ImportUrdfSetup(struct GUIHelperInterface* helper, int option, const char* fileName)
|
||||
:CommonMultiBodyBase(helper)
|
||||
{
|
||||
m_data = new ImportUrdfInternalData;
|
||||
|
||||
if (option==1)
|
||||
{
|
||||
m_useMultiBody = true;
|
||||
@@ -74,38 +85,44 @@ ImportUrdfSetup::ImportUrdfSetup(struct GUIHelperInterface* helper, int option)
|
||||
}
|
||||
|
||||
static int count = 0;
|
||||
gFileNameArray.clear();
|
||||
gFileNameArray.push_back("r2d2.urdf");
|
||||
|
||||
m_data = new ImportUrdfInternalData;
|
||||
|
||||
//load additional urdf file names from file
|
||||
|
||||
FILE* f = fopen("urdf_files.txt","r");
|
||||
if (f)
|
||||
{
|
||||
int result;
|
||||
//warning: we don't avoid string buffer overflow in this basic example in fscanf
|
||||
char fileName[1024];
|
||||
do
|
||||
{
|
||||
result = fscanf(f,"%s",fileName);
|
||||
if (result==1)
|
||||
{
|
||||
gFileNameArray.push_back(fileName);
|
||||
}
|
||||
} while (result==1);
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
int numFileNames = gFileNameArray.size();
|
||||
|
||||
if (count>=numFileNames)
|
||||
if (fileName)
|
||||
{
|
||||
count=0;
|
||||
setFileName(fileName);
|
||||
} else
|
||||
{
|
||||
gFileNameArray.clear();
|
||||
gFileNameArray.push_back("r2d2.urdf");
|
||||
|
||||
|
||||
|
||||
//load additional urdf file names from file
|
||||
|
||||
FILE* f = fopen("urdf_files.txt","r");
|
||||
if (f)
|
||||
{
|
||||
int result;
|
||||
//warning: we don't avoid string buffer overflow in this basic example in fscanf
|
||||
char fileName[1024];
|
||||
do
|
||||
{
|
||||
result = fscanf(f,"%s",fileName);
|
||||
if (result==1)
|
||||
{
|
||||
gFileNameArray.push_back(fileName);
|
||||
}
|
||||
} while (result==1);
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
int numFileNames = gFileNameArray.size();
|
||||
|
||||
if (count>=numFileNames)
|
||||
{
|
||||
count=0;
|
||||
}
|
||||
sprintf(m_fileName,gFileNameArray[count++].c_str());
|
||||
}
|
||||
sprintf(m_fileName,gFileNameArray[count++].c_str());
|
||||
}
|
||||
|
||||
ImportUrdfSetup::~ImportUrdfSetup()
|
||||
@@ -270,8 +287,8 @@ void ImportUrdfSetup::stepSimulation(float deltaTime)
|
||||
}
|
||||
}
|
||||
|
||||
class CommonExampleInterface* ImportURDFCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option)
|
||||
class CommonExampleInterface* ImportURDFCreateFunc(struct CommonExampleOptions& options)
|
||||
{
|
||||
|
||||
return new ImportUrdfSetup(helper, option);
|
||||
return new ImportUrdfSetup(options.m_guiHelper, options.m_option,options.m_fileName);
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
#define IMPORT_URDF_SETUP_H
|
||||
|
||||
|
||||
class CommonExampleInterface* ImportURDFCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option);
|
||||
class CommonExampleInterface* ImportURDFCreateFunc(struct CommonExampleOptions& options);
|
||||
|
||||
|
||||
#endif //IMPORT_URDF_SETUP_H
|
||||
|
||||
Reference in New Issue
Block a user