本文整理汇总了C++中ObjectData::addObject方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectData::addObject方法的具体用法?C++ ObjectData::addObject怎么用?C++ ObjectData::addObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectData
的用法示例。
在下文中一共展示了ObjectData::addObject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initialize
bool initialize()
{
view = glm::lookAt( glm::vec3(0, 30.0, 0), //Eye Position
glm::vec3(0, 0.0, 0.0), //Focus point
glm::vec3(0.0, 0.0, 1.0)); //Positive Y is up
projection = glm::perspective( 45.0f, //the FoV typically 90 degrees is good which is what this is set to
float(w)/float(h), //Aspect Ratio, so Circles stay Circular
0.01f, //Distance to the near plane, normally a small value like this
100.0f); //Distance to the far plane,
bool loadedSuccess = true;
objTriMesh = new btTriangleMesh();
btCollisionShape *tempShape = NULL;
btDefaultMotionState *tempMotionState = NULL;
btScalar tempMass;
btVector3 tempInertia;
btRigidBody *tempRigidBody = NULL;
//Collision Masks
int paddleColidesWith = COL_WALL | COL_PADDLE | COL_PUCK | COL_INVWALL;
//int goalColidesWith = COL_PUCK;
int wallColidesWith = COL_PUCK | COL_PADDLE;
int invWallColidesWith = COL_PADDLE;
int puckCollidesWith = COL_PADDLE | COL_GOAL | COL_WALL;
//TABLE
globalObjCount++;
Vertex *geometry;
loadedSuccess = loadOBJ("LabyrinthBoard.obj", &geometry, 0);
if ( !loadedSuccess )
{
cout << "OBJ file not found or invalid format" << endl;
return false;
}
glGenBuffers(1, &vbo_geometry);
glBindBuffer(GL_ARRAY_BUFFER, vbo_geometry);
glBufferData(GL_ARRAY_BUFFER, sizeof(geometry)*numberTriangles*4, geometry, GL_STATIC_DRAW);
//Create collision Objects
//Initalize the Hockey Table.
tempShape = new btBvhTriangleMeshShape(objTriMesh, true); //Hockey Table
tempMotionState = new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1), btVector3(0,-15,0)));
tempMass = 0;
tempInertia = btVector3(0.0f, 0.0f, 0.0f);
btRigidBody::btRigidBodyConstructionInfo shapeRigidBodyCI(tempMass, tempMotionState, tempShape, tempInertia);
tempRigidBody = new btRigidBody(shapeRigidBodyCI);
objectsDataList.addObject(0, tempShape, tempMotionState, tempMass, tempInertia, vbo_geometry, numberTriangles, 4.0f, tempRigidBody, textureFileName);
dynamicsWorld->addRigidBody(tempRigidBody, COL_WALL, wallColidesWith);
tempRigidBody = NULL;
delete geometry;
numberTriangles = 0;
objTriMesh = NULL;
//Paddle 1
globalObjCount++;
Vertex *cylinder;
//btVector3 cylinderVect = btVector3(1.15f, 1.15f, 1.15f);
objTriMesh = new btTriangleMesh();
loadedSuccess = loadOBJ("Earth.obj", &cylinder, 1);
if ( !loadedSuccess )
{
cout << "OBJ file not found or invalid format" << endl;
return false;
}
// Create a Vertex Buffer object to store this vertex info on the GPU
glGenBuffers(1, &vbo_cylinder);
glBindBuffer(GL_ARRAY_BUFFER, vbo_cylinder);
glBufferData(GL_ARRAY_BUFFER, sizeof(cylinder)*numberTriangles*4, cylinder, GL_STATIC_DRAW);
//Initalize the Cylinder
//tempShape = new btCylinderShape(cylinderVect);
tempShape = new btConvexTriangleMeshShape(objTriMesh, true); //Paddle One
tempMotionState = new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1), btVector3(-5.0f,0.0f,0.0f)));
tempMass = 10;
tempInertia = btVector3(0.0f, 0.0f, 0.0f);
tempShape->calculateLocalInertia(tempMass, tempInertia);
btRigidBody::btRigidBodyConstructionInfo paddleOneRigidBodyCI(tempMass, tempMotionState, tempShape, tempInertia);
tempRigidBody = new btRigidBody(paddleOneRigidBodyCI);
tempRigidBody->setRestitution(btScalar(0.01));
tempRigidBody->setFriction(btScalar(1));
objectsDataList.addObject(1, tempShape, tempMotionState, tempMass, tempInertia, vbo_cylinder, numberTriangles, .7f, tempRigidBody, textureFileName);
dynamicsWorld->addRigidBody(tempRigidBody, COL_PADDLE, paddleColidesWith);
delete cylinder;
tempRigidBody = NULL;
numberTriangles = 0;
objTriMesh = NULL;
//objTriMesh = new btTriangleMesh();
/*
//Paddle 2
//.........这里部分代码省略.........
示例2: initialize
bool initialize()
{
//cout << "Makes it to initalize!" << endl;
bool loadedSuccess = true;
char defualtOBJName[] = "iceRink.obj"; //Change to change the default loaded object.
btCollisionShape *tempShape = NULL;
btDefaultMotionState *tempMotionState = NULL;
btScalar tempMass;
btVector3 tempInertia;
btRigidBody *tempRigidBody = NULL;
//Collision Masks
int shapeColidesWith = COL_WALL | COL_SHAPE;
int wallColidesWith = COL_SHAPE;
//TABLE
globalObjCount++;
Vertex *geometry;
btVector3 tempVect = btVector3(0.0f, 1.0f, 0.0f);
btScalar planeScaler = 3;
objTriMesh = new btTriangleMesh();
loadedSuccess = loadOBJ(defualtOBJName, &geometry);
if ( !loadedSuccess )
{
cout << "OBJ file not found or invalid format" << endl;
return false;
}
glGenBuffers(1, &vbo_geometry);
glBindBuffer(GL_ARRAY_BUFFER, vbo_geometry);
glBufferData(GL_ARRAY_BUFFER, sizeof(geometry)*numberTriangles*3, geometry, GL_STATIC_DRAW);
//Create collision Objects
//Initalize the Hockey Table.
tempShape = new btBvhTriangleMeshShape(objTriMesh, true); //Hockey Table
//tempShape = new btStaticPlaneShape(tempVect, planeScaler);
tempMotionState = new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1), btVector3(0,-15,0)));
tempMass = 0;
tempInertia = btVector3(0.0f, 0.0f, 0.0f);
tempShape->calculateLocalInertia(tempMass, tempInertia);
btRigidBody::btRigidBodyConstructionInfo shapeRigidBodyCI(tempMass, tempMotionState, tempShape, tempInertia);
tempRigidBody = new btRigidBody(shapeRigidBodyCI);
objectsDataList.addObject(0, tempShape, tempMotionState, tempMass, tempInertia, vbo_geometry, numberTriangles, 1, tempRigidBody);
dynamicsWorld->addRigidBody(tempRigidBody, COL_WALL, wallColidesWith);
tempRigidBody = NULL;
delete geometry;
numberTriangles = 0;
delete objTriMesh;
objTriMesh = new btTriangleMesh();
//cout << "Makes it past loading the table!" << endl;
/*
//CUBE
globalObjCount++;
Vertex *Cube;
objTriMesh = new btTriangleMesh();
btVector3 squareVect = btVector3(0.6f, 0.6f, 0.6f);
loadedSuccess = loadOBJ("Cube.obj", &Cube);
if ( !loadedSuccess )
{
cout << "OBJ file not found or invalid format" << endl;
return false;
}
// Create a Vertex Buffer object to store this vertex info on the GPU
glGenBuffers(1, &vbo_cube);
glBindBuffer(GL_ARRAY_BUFFER, vbo_cube);
glBufferData(GL_ARRAY_BUFFER, sizeof(Cube)*numberTriangles*3, Cube, GL_STATIC_DRAW);
//Initalize the Cube.
//tempShape = new btBvhTriangleMeshShape(objTriMesh, true);//Cube
tempShape = new btBoxShape(squareVect);
tempMotionState = new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1), btVector3(0.5f,4.0f,0.0f)));
tempMass = 1;
tempInertia = btVector3(0.0f, 0.0f, 0.0f);
objectsDataList.addObject(1, tempShape, tempMotionState, tempMass, tempInertia, vbo_cube, numberTriangles, .5f);
dynamicsWorld->addRigidBody(objectsDataList.getRigidBody(1), COL_SHAPE, shapeColidesWith);
delete Cube;
numberTriangles = 0;
delete objTriMesh;
objTriMesh = new btTriangleMesh();
*/
//CYLINDER
//Paddle 1
globalObjCount++;
Vertex *cylinder;
btVector3 cylinderVect = btVector3(0.6f, 0.6f, 0.6f);
objTriMesh = new btTriangleMesh();
loadedSuccess = loadOBJ("Paddle.obj", &cylinder);
if ( !loadedSuccess )
{
cout << "OBJ file not found or invalid format" << endl;
return false;
//.........这里部分代码省略.........