diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp index 9e52e218..8fecd86f 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -285,8 +285,8 @@ void GameState::InitiatePlayer(int id, std::wstring modelName, Oyster::Math::Flo modelData.visible = true; //modelData.world = world; modelData.position = Oyster::Math::Float3(world[12], world[13], world[14]); - modelData.rotation = Oyster::Math::Quaternion(Oyster::Math::Float3(2,2,-2), 1); - modelData.scale = Oyster::Math::Float3(2,2,2); + modelData.rotation = Oyster::Math::Quaternion(Oyster::Math::Float3(0,0,0), 1); + modelData.scale = Oyster::Math::Float3(1,1,1); modelData.modelPath = modelName; modelData.id = myId; @@ -565,7 +565,9 @@ void GameState::Protocol( ObjPos* pos ) { if(dynamicObjects[i]->GetId() == pos->object_ID) { - dynamicObjects[i]->setWorld(world); + + dynamicObjects[i]->setPos(Float3(world[12], world[13], world[14])); + if(dynamicObjects[i]->GetId() == myId) // playerobj { diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp index ec571b9f..06d461fa 100644 --- a/Code/Game/GameLogic/Level.cpp +++ b/Code/Game/GameLogic/Level.cpp @@ -51,6 +51,8 @@ void Level::InitiateLevel(std::string levelPath) objects = ll.LoadLevel(levelPath); int objCount = objects.size(); int modelCount = 0; + int staticObjCount = 0; + int dynamicObjCount = 0; for (int i = 0; i < objCount; i++) { ObjectTypeHeader* obj = objects.at(i); @@ -71,121 +73,33 @@ void Level::InitiateLevel(std::string levelPath) //LevelLoaderInternal::BoundingVolumeBase* staticObjPhysicData = ((ObjectHeader*)obj); staticObjData->ModelFile; - ICustomBody* rigidBody_Static; - //if( staticObjPhysicData->geometryType = CollisionGeometryType_Box) - //{ - // //API::SimpleBodyDescription sbDesc_Static; - - // //sbDesc_Static.centerPosition = staticObjData->position; - // //sbDesc_Static.ignoreGravity = false; // because it is static - // //sbDesc_Static.rotation = Oyster::Math::Float3(staticObjData->rotation[0], staticObjData->rotation[1],staticObjData->rotation[2]);//Oyster::Math::Float3(0 ,Utility::Value::Radian(90.0f), 0); + ICustomBody* rigidBody_Static; + // collision shape + // radius, rotation in world, position in world, mass, restitution, static and dynamic friction + ICustomBody* rigidBody = API::Instance().AddCollisionSphere(599.2f, Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0, 0.5f, 0.8f, 0.6f); + + // add rigidbody to the logical obj + // Object::DefaultCollisionBefore, Object::DefaultCollisionAfter for now, gamelogic will take care of this + // set object_type to objID + this->staticObjects.Push(new StaticObject(rigidBody,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX)); - // ////sbDesc_Static.inertiaTensor.Cuboid(staticObjPhysicData->mass); - // //sbDesc_Static.mass = staticObjPhysicData->mass; - // //sbDesc_Static.frictionCoeff_Static = staticObjPhysicData->frictionCoeffStatic; - // //sbDesc_Static.frictionCoeff_Dynamic = staticObjPhysicData->frictionCoeffDynamic; - // ////sbDesc_Static.restitutionCoeff = - // //sbDesc_Static.size = Oyster::Math::Float3(40,40,40); - // //rigidBody_Static = API::Instance().CreateRigidBody(sbDesc_Static).Release(); - // //if(rigidBody_Static) - // //{ - // // this->staticObjects.Push(new StaticObject(rigidBody_Static,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_GENERIC)); - // // int id = this->staticObjects.Size()-1; - // // rigidBody_Static->SetCustomTag(this->staticObjects[this->staticObjects.Size()-1]); - // //} - //} - //if( staticObjPhysicData->geometryType = CollisionGeometryType_Sphere) - //{ - // //API::SphericalBodyDescription sbDesc_Static; - - // //sbDesc_Static.centerPosition = staticObjData->position; - // //sbDesc_Static.ignoreGravity = true; // because it is static - // //sbDesc_Static.rotation = Oyster::Math::Float3(staticObjData->rotation[0], staticObjData->rotation[1],staticObjData->rotation[2]);//Oyster::Math::Float3(0 ,Utility::Value::Radian(90.0f), 0); - - // ////sbDesc_Static.inertiaTensor.Sphere(staticObjPhysicData->mass); - - // //sbDesc_Static.mass = staticObjPhysicData->mass; - // //sbDesc_Static.frictionCoeff_Static = staticObjPhysicData->frictionCoeffStatic; - // //sbDesc_Static.frictionCoeff_Dynamic = staticObjPhysicData->frictionCoeffDynamic; - // ////sbDesc_Static.restitutionCoeff = - // ////sbDesc_Static.radius = - // //rigidBody_Static = API::Instance().CreateRigidBody(sbDesc_Static).Release(); - // if(rigidBody_Static) - // { - // this->staticObjects.Push(new StaticObject(rigidBody_Static,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_GENERIC)); - // int id = this->staticObjects.Size()-1; - // rigidBody_Static->SetCustomTag(this->staticObjects[this->staticObjects.Size()-1]); - // } - - // if (OBJECT_TYPE::OBJECT_TYPE_WORLD) - // { - // /*API::Gravity gravityWell; - // gravityWell.gravityType = API::Gravity::GravityType_Well; - // gravityWell.well.mass = 1e17f; - // gravityWell.well.position = Oyster::Math::Float4(0,0,0,1); - // API::Instance().AddGravity(gravityWell);*/ - // } - //} + this->staticObjects[staticObjCount]->objectID = modelCount++; + rigidBody->SetCustomTag(this->staticObjects[staticObjCount]); } break; case ObjectType::ObjectType_Dynamic: { ObjectHeader* staticObjData = ((ObjectHeader*)obj); - //LevelLoaderInternal::BoundingVolumeBase* staticObjPhysicData = ((ObjectHeader*)obj); staticObjData->ModelFile; ICustomBody* rigidBody_Dynamic; - //if( staticObjPhysicData->geometryType = CollisionGeometryType_Box) - //{ - // //API::Instance().AddCollisionBox() - // //API::SimpleBodyDescription sbDesc_Dynamic; - // //sbDesc_Dynamic.centerPosition = staticObjData->position; - // //sbDesc_Dynamic.ignoreGravity = false; // because it is static - // //sbDesc_Dynamic.rotation = Oyster::Math::Float3(staticObjData->rotation[0], staticObjData->rotation[1],staticObjData->rotation[2]);//Oyster::Math::Float3(0 ,Utility::Value::Radian(90.0f), 0); + rigidBody_Dynamic = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 605 + i*5, 10), 5, 0.5f, 0.8f, 0.6f); - - // ////sbDesc_Static.inertiaTensor.Cuboid(staticObjPhysicData->mass); - // //sbDesc_Dynamic.mass = staticObjPhysicData->mass; - // //sbDesc_Dynamic.frictionCoeff_Static = staticObjPhysicData->frictionCoeffStatic; - // //sbDesc_Dynamic.frictionCoeff_Dynamic = staticObjPhysicData->frictionCoeffDynamic; - // ////sbDesc_Static.restitutionCoeff = - // //sbDesc_Dynamic.size = Oyster::Math::Float3(40,40,40); - // //rigidBody_Dynamic = API::Instance().CreateRigidBody(sbDesc_Dynamic).Release(); - // //if(rigidBody_Dynamic) - // //{ - // // rigidBody_Dynamic->SetSubscription(Level::PhysicsOnMoveLevel); - // // this->dynamicObjects.Push(new DynamicObject(rigidBody_Dynamic,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_GENERIC)); - // // int id = this->dynamicObjects.Size()-1; - // // rigidBody_Dynamic->SetCustomTag(this->dynamicObjects[this->dynamicObjects.Size()-1]); - // //} - //} - //if( staticObjPhysicData->geometryType = CollisionGeometryType_Sphere) - //{ - // //API::Instance().AddCollisionBox() - // //API::SphericalBodyDescription sbDesc_Dynamic; - - // //sbDesc_Dynamic.centerPosition = staticObjData->position; - // //sbDesc_Dynamic.ignoreGravity = false; // use gravity on dynamic obj - // //sbDesc_Dynamic.rotation = Oyster::Math::Float3(staticObjData->rotation[0], staticObjData->rotation[1],staticObjData->rotation[2]);//Oyster::Math::Float3(0 ,Utility::Value::Radian(90.0f), 0); - - // ////sbDesc_Static.inertiaTensor.Sphere(staticObjPhysicData->mass); - - // //sbDesc_Dynamic.mass = staticObjPhysicData->mass; - // //sbDesc_Dynamic.frictionCoeff_Static = staticObjPhysicData->frictionCoeffStatic; - // //sbDesc_Dynamic.frictionCoeff_Dynamic = staticObjPhysicData->frictionCoeffDynamic; - // ////sbDesc_Static.restitutionCoeff = - // ////sbDesc_Static.radius = - // //rigidBody_Dynamic = API::Instance().CreateRigidBody(sbDesc_Dynamic).Release(); - // //if(rigidBody_Dynamic) - // //{ - // // rigidBody_Dynamic->SetSubscription(Level::PhysicsOnMoveLevel); - // // this->dynamicObjects.Push(new DynamicObject(rigidBody_Dynamic,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_GENERIC)); - // // int id = this->dynamicObjects.Size()-1; - // // rigidBody_Dynamic->SetCustomTag(this->dynamicObjects[this->dynamicObjects.Size()-1]); - // //} - //} + this->dynamicObjects.Push(new DynamicObject(rigidBody_Dynamic,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX)); + this->dynamicObjects[dynamicObjCount]->objectID = modelCount++; + rigidBody_Dynamic->SetCustomTag(this->dynamicObjects[dynamicObjCount]); } break; case ObjectType::ObjectType_Light: