GL - initiating ccc map from folder ../Content/Worlds. Sync with graphics content.
This commit is contained in:
parent
d01acbcbe0
commit
2dee9dd084
|
@ -77,10 +77,10 @@ GameState::gameStateState GameState::LoadGame()
|
||||||
|
|
||||||
//Oyster::Graphics::API::AddLight(plight);
|
//Oyster::Graphics::API::AddLight(plight);
|
||||||
// use level loader
|
// use level loader
|
||||||
//LoadModels("3bana.bias");
|
LoadModels("../Content/Worlds/ccc.bias");
|
||||||
|
|
||||||
// hardcoded objects
|
// hardcoded objects
|
||||||
LoadModels("C:/Users/Sam/Documents/GitHub/Danbias/Bin/Content/worlds/ccc.bias");
|
//LoadModels();
|
||||||
Float3 startPos = Float3(0,0,20.0f);
|
Float3 startPos = Float3(0,0,20.0f);
|
||||||
InitCamera(startPos);
|
InitCamera(startPos);
|
||||||
return gameStateState_playing;
|
return gameStateState_playing;
|
||||||
|
@ -185,7 +185,7 @@ bool GameState::LoadModels(std::string mapFile)
|
||||||
objects = levelLoader.LoadLevel(mapFile);
|
objects = levelLoader.LoadLevel(mapFile);
|
||||||
|
|
||||||
int objCount = objects.size();
|
int objCount = objects.size();
|
||||||
int modelId = 0;
|
int modelId = 100;
|
||||||
ModelInitData modelData;
|
ModelInitData modelData;
|
||||||
for (int i = 0; i < objCount; i++)
|
for (int i = 0; i < objCount; i++)
|
||||||
{
|
{
|
||||||
|
@ -244,19 +244,19 @@ bool GameState::LoadModels(std::string mapFile)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
myId += modelId++;
|
//myId += modelId++;
|
||||||
// add player model
|
// add player model
|
||||||
//modelData.position = ;
|
//modelData.position = ;
|
||||||
//modelData.rotation = Oyster::Math::Quaternion(Oyster::Math::Float3(2,2,-2), 1);
|
//modelData.rotation = Oyster::Math::Quaternion(Oyster::Math::Float3(2,2,-2), 1);
|
||||||
//modelData.scale = Oyster::Math::Float3(2,2,2);
|
//modelData.scale = Oyster::Math::Float3(2,2,2);
|
||||||
|
|
||||||
|
|
||||||
modelData.visible = true;
|
//modelData.visible = true;
|
||||||
modelData.modelPath = L"char_still_sizeref.dan";
|
//modelData.modelPath = L"char_still_sizeref.dan";
|
||||||
modelData.id = myId;
|
//modelData.id = myId;
|
||||||
// load models
|
//// load models
|
||||||
this->dynamicObjects.Push(new C_DynamicObj());
|
//this->dynamicObjects.Push(new C_DynamicObj());
|
||||||
this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData);
|
//this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData);
|
||||||
|
|
||||||
/*C_Player* obj = new C_Player();
|
/*C_Player* obj = new C_Player();
|
||||||
privData->object.push_back(obj);
|
privData->object.push_back(obj);
|
||||||
|
|
|
@ -147,7 +147,7 @@ namespace GameLogic
|
||||||
//Läs in filen.
|
//Läs in filen.
|
||||||
int fileLength = 0;
|
int fileLength = 0;
|
||||||
Loader loader;
|
Loader loader;
|
||||||
char* buf = loader.LoadFile("C:/Users/Sam/Documents/GitHub/Danbias/Bin/Content/worlds/cgf/"+ fileName, fileLength);
|
char* buf = loader.LoadFile("../Content/Worlds/cgf/"+ fileName, fileLength);
|
||||||
|
|
||||||
start = 0;
|
start = 0;
|
||||||
LevelLoaderInternal::FormatVersion version;
|
LevelLoaderInternal::FormatVersion version;
|
||||||
|
|
|
@ -37,6 +37,7 @@ using namespace GameLogic;
|
||||||
PlayerVObject(*player,*realObj, kineticEnergyLoss);
|
PlayerVObject(*player,*realObj, kineticEnergyLoss);
|
||||||
//player->playerState = PLAYER_STATE::PLAYER_STATE_WALKING;
|
//player->playerState = PLAYER_STATE::PLAYER_STATE_WALKING;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//return Physics::ICustomBody::SubscriptMessage_none;
|
//return Physics::ICustomBody::SubscriptMessage_none;
|
||||||
|
|
|
@ -82,7 +82,7 @@ Game::LevelData* Game::CreateLevel()
|
||||||
|
|
||||||
this->level = new LevelData();
|
this->level = new LevelData();
|
||||||
//this->level->level->InitiateLevel(1000);
|
//this->level->level->InitiateLevel(1000);
|
||||||
this->level->level->InitiateLevel("C:/Users/Sam/Documents/GitHub/Danbias/Bin/Content/worlds/ccc.bias");
|
this->level->level->InitiateLevel("../Content/Worlds/ccc.bias");
|
||||||
|
|
||||||
return this->level;
|
return this->level;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,9 +7,9 @@ Game::PlayerData::PlayerData()
|
||||||
{
|
{
|
||||||
//set some stats that are appropriate to a player
|
//set some stats that are appropriate to a player
|
||||||
|
|
||||||
Oyster::Math::Float3 centerPosition = Oyster::Math::Float3(0,400,0);
|
Oyster::Math::Float3 centerPosition = Oyster::Math::Float3(50,130,0);
|
||||||
|
|
||||||
Oyster::Math::Float3 size = Oyster::Math::Float3(0.25f,1.0f,0.5f);
|
Oyster::Math::Float3 size = Oyster::Math::Float3(0.25f,2.0f,0.5f);
|
||||||
Oyster::Math::Float mass = 60;
|
Oyster::Math::Float mass = 60;
|
||||||
Oyster::Math::Float restitutionCoeff = 0.5;
|
Oyster::Math::Float restitutionCoeff = 0.5;
|
||||||
Oyster::Math::Float frictionCoeff_Static = 0.4;
|
Oyster::Math::Float frictionCoeff_Static = 0.4;
|
||||||
|
|
|
@ -16,48 +16,190 @@ Level::~Level(void)
|
||||||
delete this->levelObj;
|
delete this->levelObj;
|
||||||
this->levelObj = NULL;
|
this->levelObj = NULL;
|
||||||
}
|
}
|
||||||
void Level::parseObjectType(ObjectTypeHeader* obj)
|
Object* Level::createGameObj(ObjectHeader* obj, ICustomBody* rigidBody)
|
||||||
{
|
{
|
||||||
/*switch (obj->objectTypeID)
|
Object* gameObj =NULL;
|
||||||
|
switch ((ObjectSpecialType)obj->specialTypeID)
|
||||||
{
|
{
|
||||||
case skySphere:
|
case ObjectSpecialType_None:
|
||||||
// save the skysphere to be able to rotate it
|
{
|
||||||
|
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case jumppad:
|
case ObjectSpecialType_Sky:
|
||||||
// save direction
|
{
|
||||||
break;
|
float skySize = ((SkyAttributes*)obj)->skySize;
|
||||||
case portal:
|
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID);
|
||||||
// save portal destination
|
}
|
||||||
break;
|
|
||||||
case world:
|
|
||||||
// add gravitation well here
|
|
||||||
// add outer limit of the world
|
|
||||||
case spawn:
|
|
||||||
// save spawnpoint pos
|
|
||||||
break;
|
break;
|
||||||
|
case ObjectSpecialType_World:
|
||||||
|
{
|
||||||
|
API::Instance().SetGravityPoint(Oyster::Math3D::Float3(0,0,0));
|
||||||
|
API::Instance().SetGravity(200); // could balance gravitation with the world size
|
||||||
|
|
||||||
default:
|
float worldSize = ((WorldAttributes*)obj)->worldSize;
|
||||||
|
float atmosphereSize = ((WorldAttributes*)obj)->atmoSphereSize;
|
||||||
|
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}*/
|
case ObjectSpecialType_Building:
|
||||||
|
{
|
||||||
|
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID);
|
||||||
|
}
|
||||||
|
case ObjectSpecialType_Stone:
|
||||||
|
{
|
||||||
|
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ObjectSpecialType_StandarsBox:
|
||||||
|
{
|
||||||
|
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ObjectSpecialType_RedExplosiveBox:
|
||||||
|
{
|
||||||
|
int dmg = 50;
|
||||||
|
//gameObj = new ExplosiveBox(rigidBody, ObjectSpecialType_RedExplosiveBox);
|
||||||
|
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
//case ObjectSpecialType_BlueExplosiveBox:
|
||||||
|
// int dmg = 70;
|
||||||
|
// gameObj = new ExplosiveBox(rigidBody, ObjectSpecialType_BlueExplosiveBox);
|
||||||
|
// break;
|
||||||
|
case ObjectSpecialType_SpikeBox:
|
||||||
|
{
|
||||||
|
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ObjectSpecialType_Spike:
|
||||||
|
{
|
||||||
|
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ObjectSpecialType_CrystalFormation:
|
||||||
|
{
|
||||||
|
int dmg = 50;
|
||||||
|
//gameObj = new Crystal(rigidBody);
|
||||||
|
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ObjectSpecialType_CrystalShard:
|
||||||
|
{
|
||||||
|
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ObjectSpecialType_JumpPad:
|
||||||
|
{
|
||||||
|
float power = ((JumpPadAttributes*)obj)->power;
|
||||||
|
Oyster::Math::Float3 dir = ((JumpPadAttributes*)obj)->direction;
|
||||||
|
//gameObj = JumpPad(rigidBody, );
|
||||||
|
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ObjectSpecialType_Portal:
|
||||||
|
{
|
||||||
|
Oyster::Math::Float3 destination = ((PortalAttributes*)obj)->destination;
|
||||||
|
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ObjectSpecialType_SpawnPoint:
|
||||||
|
{
|
||||||
|
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ObjectSpecialType_Player:
|
||||||
|
{
|
||||||
|
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ObjectSpecialType_Generic:
|
||||||
|
{
|
||||||
|
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return gameObj;
|
||||||
}
|
}
|
||||||
void Level::parsePhysicsObj(LevelLoaderInternal::BoundingVolumeBase* obj)
|
|
||||||
|
ICustomBody* Level::InitRigidBodyCube( const ObjectHeader* obj)
|
||||||
{
|
{
|
||||||
// offset physObj med modelObj
|
ICustomBody* rigidBody = NULL;
|
||||||
|
Oyster::Math::Float3 rigidWorldPos;
|
||||||
|
Oyster::Math::Float4 rigidWorldRotation;
|
||||||
|
float rigidBodyMass;
|
||||||
|
Oyster::Math::Float3 rigidBodySize;
|
||||||
|
|
||||||
|
//offset the rigidPosition from modelspace to worldspace;
|
||||||
|
rigidWorldPos = (Oyster::Math::Float3)obj->position + (Oyster::Math::Float3)obj->boundingVolume.box.position;
|
||||||
|
//scales the position so the collision geomentry is in the right place
|
||||||
|
rigidWorldPos = rigidWorldPos * obj->scale;
|
||||||
|
|
||||||
|
//offset the rigidRotation from modelspace to worldspace;
|
||||||
|
Oyster::Math::Quaternion worldPosQuaternion = Oyster::Math::Quaternion(Oyster::Math::Float3(obj->rotation[0],obj->rotation[1],obj->rotation[2]), obj->rotation[3]);
|
||||||
|
Oyster::Math::Quaternion physicsPosQuaternion = Oyster::Math::Quaternion(Oyster::Math::Float3(obj->boundingVolume.sphere.rotation[0],obj->boundingVolume.sphere.rotation[1],obj->boundingVolume.sphere.rotation[2]), obj->boundingVolume.sphere.rotation[3]);
|
||||||
|
Oyster::Math::Quaternion rigidWorldQuaternion = worldPosQuaternion * physicsPosQuaternion;
|
||||||
|
|
||||||
|
rigidWorldRotation = Oyster::Math::Float4(rigidWorldQuaternion);
|
||||||
|
|
||||||
|
//mass scaled
|
||||||
|
rigidBodyMass = obj->scale[0] * obj->scale[1] * obj->scale[2] * obj->boundingVolume.box.mass;
|
||||||
|
|
||||||
|
//size scaled
|
||||||
|
rigidBodySize = (Oyster::Math::Float3)obj->boundingVolume.box.size * (Oyster::Math::Float3)obj->scale;
|
||||||
|
|
||||||
|
//create the rigid body
|
||||||
|
rigidBody = API::Instance().AddCollisionBox(rigidBodySize , rigidWorldRotation , rigidWorldPos , rigidBodyMass, obj->boundingVolume.box.restitutionCoeff , obj->boundingVolume.box.frictionCoeffStatic , obj->boundingVolume.box.frictionCoeffDynamic);
|
||||||
|
return rigidBody;
|
||||||
|
}
|
||||||
|
ICustomBody* Level::InitRigidBodySphere( const ObjectHeader* obj)
|
||||||
|
{
|
||||||
|
ICustomBody* rigidBody = NULL;
|
||||||
|
Oyster::Math::Float3 rigidWorldPos;
|
||||||
|
Oyster::Math::Float4 rigidWorldRotation;
|
||||||
|
float rigidBodyMass;
|
||||||
|
float rigidBodyRadius;
|
||||||
|
|
||||||
|
//offset the rigidPosition from modelspace to worldspace;
|
||||||
|
rigidWorldPos = (Oyster::Math::Float3)obj->position + (Oyster::Math::Float3)obj->boundingVolume.sphere.position;
|
||||||
|
//scales the position so the collision geomentry is in the right place
|
||||||
|
rigidWorldPos = rigidWorldPos * obj->scale;
|
||||||
|
|
||||||
|
//offset the rigidRotation from modelspace to worldspace;
|
||||||
|
Oyster::Math::Quaternion worldPosQuaternion = Oyster::Math::Quaternion(Oyster::Math::Float3(obj->rotation[0],obj->rotation[1],obj->rotation[2]), obj->rotation[3]);
|
||||||
|
Oyster::Math::Quaternion physicsPosQuaternion = Oyster::Math::Quaternion(Oyster::Math::Float3(obj->boundingVolume.sphere.rotation[0],obj->boundingVolume.sphere.rotation[1],obj->boundingVolume.sphere.rotation[2]), obj->boundingVolume.sphere.rotation[3]);
|
||||||
|
Oyster::Math::Quaternion rigidWorldQuaternion = worldPosQuaternion * physicsPosQuaternion;
|
||||||
|
|
||||||
|
rigidWorldRotation = Oyster::Math::Float4(rigidWorldQuaternion);
|
||||||
|
|
||||||
|
|
||||||
|
//mass scaled
|
||||||
|
rigidBodyMass = obj->scale[0] * obj->scale[1] * obj->scale[2] * obj->boundingVolume.sphere.mass;
|
||||||
|
|
||||||
|
//Radius scaled
|
||||||
|
//rigidBodyRadius = (staticObjData->scale[0] * staticObjData->scale[1] * staticObjData->scale[2] / 3) * staticObjData->boundingVolume.sphere.radius;
|
||||||
|
rigidBodyRadius = (obj->scale[0] * obj->scale[1] * obj->scale[2]) * obj->boundingVolume.sphere.radius;
|
||||||
|
|
||||||
|
//create the rigid body
|
||||||
|
rigidBody = API::Instance().AddCollisionSphere( rigidBodyRadius , rigidWorldRotation , rigidWorldPos , rigidBodyMass, obj->boundingVolume.sphere.restitutionCoeff , obj->boundingVolume.sphere.frictionCoeffStatic , obj->boundingVolume.sphere.frictionCoeffDynamic);
|
||||||
|
return rigidBody;
|
||||||
}
|
}
|
||||||
void Level::InitiateLevel(std::string levelPath)
|
void Level::InitiateLevel(std::string levelPath)
|
||||||
{
|
{
|
||||||
LevelLoader ll;
|
LevelLoader ll;
|
||||||
std::vector<Utility::DynamicMemory::SmartPointer<ObjectTypeHeader>> objects;
|
std::vector<Utility::DynamicMemory::SmartPointer<ObjectTypeHeader>> objects;
|
||||||
objects = ll.LoadLevel(levelPath);
|
objects = ll.LoadLevel(levelPath);
|
||||||
|
|
||||||
|
API::Instance().SetGravityPoint(Oyster::Math3D::Float3(0,0,0));
|
||||||
|
API::Instance().SetGravity(200);
|
||||||
int objCount = objects.size();
|
int objCount = objects.size();
|
||||||
int modelCount = 0;
|
int modelCount = 100;
|
||||||
int staticObjCount = 0;
|
|
||||||
int dynamicObjCount = 0;
|
|
||||||
Oyster::Math::Float3 rigidWorldPos;
|
|
||||||
Oyster::Math::Float4 rigidWorldRotation;
|
|
||||||
float rigidBodyMass;
|
|
||||||
float rigidBodyRadius;
|
|
||||||
Oyster::Math::Float3 rigidBodySize;
|
|
||||||
for (int i = 0; i < objCount; i++)
|
for (int i = 0; i < objCount; i++)
|
||||||
{
|
{
|
||||||
ObjectTypeHeader* obj = objects.at(i);
|
ObjectTypeHeader* obj = objects.at(i);
|
||||||
|
@ -75,69 +217,37 @@ void Level::InitiateLevel(std::string levelPath)
|
||||||
{
|
{
|
||||||
|
|
||||||
ObjectHeader* staticObjData = ((ObjectHeader*)obj);
|
ObjectHeader* staticObjData = ((ObjectHeader*)obj);
|
||||||
//LevelLoaderInternal::BoundingVolumeBase* staticObjPhysicData = ((ObjectHeader*)obj);
|
|
||||||
staticObjData->ModelFile;
|
staticObjData->ModelFile;
|
||||||
|
|
||||||
ICustomBody* rigidBody_Static = NULL;
|
ICustomBody* rigidBody_Static = NULL;
|
||||||
|
|
||||||
|
|
||||||
// collision shape
|
// collision shape
|
||||||
// radius, rotation in world, position in world, mass, restitution, static and dynamic friction
|
|
||||||
if(staticObjData->boundingVolume.geoType == CollisionGeometryType_Sphere)
|
if(staticObjData->boundingVolume.geoType == CollisionGeometryType_Sphere)
|
||||||
{
|
{
|
||||||
//offset the rigidPosition from modelspace to worldspace;
|
rigidBody_Static = InitRigidBodySphere(staticObjData);
|
||||||
rigidWorldPos = (Oyster::Math::Float3)staticObjData->position + (Oyster::Math::Float3)staticObjData->boundingVolume.sphere.position;
|
|
||||||
//scales the position so the collision geomentry is in the right place
|
|
||||||
rigidWorldPos = rigidWorldPos * staticObjData->scale;
|
|
||||||
|
|
||||||
//offset the rigidRotation from modelspace to worldspace;
|
|
||||||
rigidWorldRotation = (Oyster::Math::Float4)staticObjData->rotation + (Oyster::Math::Float4)staticObjData->boundingVolume.sphere.rotation;
|
|
||||||
|
|
||||||
//mass scaled
|
|
||||||
rigidBodyMass = staticObjData->scale[0] * staticObjData->scale[1] * staticObjData->scale[2] * staticObjData->boundingVolume.sphere.mass;
|
|
||||||
|
|
||||||
//Radius scaled
|
|
||||||
rigidBodyRadius = (staticObjData->scale[0] * staticObjData->scale[1] * staticObjData->scale[2] / 3) * staticObjData->boundingVolume.sphere.radius;
|
|
||||||
|
|
||||||
//create the rigid body
|
|
||||||
rigidBody_Static = API::Instance().AddCollisionSphere( rigidBodyRadius , rigidWorldRotation , rigidWorldPos , rigidBodyMass, staticObjData->boundingVolume.sphere.restitutionCoeff , staticObjData->boundingVolume.sphere.frictionCoeffStatic , staticObjData->boundingVolume.sphere.frictionCoeffDynamic);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(staticObjData->boundingVolume.geoType == CollisionGeometryType_Box)
|
else if(staticObjData->boundingVolume.geoType == CollisionGeometryType_Box)
|
||||||
{
|
{
|
||||||
//offset the rigidPosition from modelspace to worldspace;
|
|
||||||
rigidWorldPos = (Oyster::Math::Float3)staticObjData->position + (Oyster::Math::Float3)staticObjData->boundingVolume.box.position;
|
|
||||||
//scales the position so the collision geomentry is in the right place
|
|
||||||
rigidWorldPos = rigidWorldPos * staticObjData->scale;
|
|
||||||
|
|
||||||
//offset the rigidRotation from modelspace to worldspace;
|
rigidBody_Static = InitRigidBodySphere(staticObjData);
|
||||||
rigidWorldRotation = (Oyster::Math::Float4)staticObjData->rotation + (Oyster::Math::Float4)staticObjData->boundingVolume.box.rotation;
|
|
||||||
|
|
||||||
//mass scaled
|
|
||||||
rigidBodyMass = staticObjData->scale[0] * staticObjData->scale[1] * staticObjData->scale[2] * staticObjData->boundingVolume.box.mass;
|
|
||||||
|
|
||||||
//size scaled
|
|
||||||
rigidBodySize = (Oyster::Math::Float3)staticObjData->boundingVolume.box.size * (Oyster::Math::Float3)staticObjData->scale;
|
|
||||||
|
|
||||||
//create the rigid body
|
|
||||||
rigidBody_Static = API::Instance().AddCollisionBox(rigidBodySize , rigidWorldRotation , rigidWorldPos , rigidBodyMass, staticObjData->boundingVolume.box.restitutionCoeff , staticObjData->boundingVolume.box.frictionCoeffStatic , staticObjData->boundingVolume.box.frictionCoeffDynamic);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(staticObjData->boundingVolume.geoType == CollisionGeometryType_Cylinder)
|
else if(staticObjData->boundingVolume.geoType == CollisionGeometryType_Cylinder)
|
||||||
{
|
{
|
||||||
|
//rigidBody_Static = InitRigidBodyCylinder(staticObjData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// add rigidbody to the logical obj
|
|
||||||
// Object::DefaultCollisionBefore, Object::DefaultCollisionAfter for now, gamelogic will take care of this
|
|
||||||
// set object_type to objID
|
|
||||||
|
|
||||||
if(rigidBody_Static != NULL)
|
if(rigidBody_Static != NULL)
|
||||||
{
|
{
|
||||||
this->staticObjects.Push(new StaticObject(rigidBody_Static, Object::DefaultCollisionAfter, (ObjectSpecialType)staticObjData->specialTypeID));
|
// create game object
|
||||||
this->staticObjects[staticObjCount]->objectID = modelCount++;
|
Object* staticGameObj = createGameObj(staticObjData, rigidBody_Static);
|
||||||
rigidBody_Static->SetCustomTag(this->staticObjects[staticObjCount]);
|
if(staticGameObj != NULL)
|
||||||
|
{
|
||||||
|
this->staticObjects.Push((StaticObject*)staticGameObj);
|
||||||
|
this->staticObjects[this->staticObjects.Size()-1]->objectID = modelCount++;
|
||||||
|
rigidBody_Static->SetCustomTag(this->staticObjects[this->staticObjects.Size()-1]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -150,61 +260,31 @@ void Level::InitiateLevel(std::string levelPath)
|
||||||
ICustomBody* rigidBody_Dynamic = NULL;
|
ICustomBody* rigidBody_Dynamic = NULL;
|
||||||
|
|
||||||
// collision shape
|
// collision shape
|
||||||
// radius, rotation in world, position in world, mass, restitution, static and dynamic friction
|
|
||||||
if(dynamicObjData->boundingVolume.geoType == CollisionGeometryType_Sphere)
|
if(dynamicObjData->boundingVolume.geoType == CollisionGeometryType_Sphere)
|
||||||
{
|
{
|
||||||
//offset the rigidPosition from modelspace to worldspace;
|
rigidBody_Dynamic = InitRigidBodySphere(dynamicObjData);
|
||||||
rigidWorldPos = (Oyster::Math::Float3)dynamicObjData->position + (Oyster::Math::Float3)dynamicObjData->boundingVolume.sphere.position;
|
|
||||||
//scales the position so the collision geomentry is in the right place
|
|
||||||
rigidWorldPos = rigidWorldPos * dynamicObjData->scale;
|
|
||||||
|
|
||||||
//offset the rigidRotation from modelspace to worldspace;
|
|
||||||
rigidWorldRotation = (Oyster::Math::Float4)dynamicObjData->rotation + (Oyster::Math::Float4)dynamicObjData->boundingVolume.sphere.rotation;
|
|
||||||
|
|
||||||
//mass scaled
|
|
||||||
rigidBodyMass = dynamicObjData->scale[0] * dynamicObjData->scale[1] * dynamicObjData->scale[2] * dynamicObjData->boundingVolume.sphere.mass;
|
|
||||||
|
|
||||||
//size scaled
|
|
||||||
rigidBodyRadius = (dynamicObjData->scale[0] * dynamicObjData->scale[1] * dynamicObjData->scale[2] / 3) * dynamicObjData->boundingVolume.sphere.radius;
|
|
||||||
|
|
||||||
//create the rigid body
|
|
||||||
rigidBody_Dynamic = API::Instance().AddCollisionBox(rigidBodyRadius , rigidWorldRotation , rigidWorldPos , rigidBodyMass, dynamicObjData->boundingVolume.sphere.restitutionCoeff , dynamicObjData->boundingVolume.sphere.frictionCoeffStatic , dynamicObjData->boundingVolume.sphere.frictionCoeffDynamic);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(dynamicObjData->boundingVolume.geoType == CollisionGeometryType_Box)
|
else if(dynamicObjData->boundingVolume.geoType == CollisionGeometryType_Box)
|
||||||
{
|
{
|
||||||
//offset the rigidPosition from modelspace to worldspace;
|
rigidBody_Dynamic = InitRigidBodyCube(dynamicObjData);
|
||||||
rigidWorldPos = (Oyster::Math::Float3)dynamicObjData->position + (Oyster::Math::Float3)dynamicObjData->boundingVolume.box.position;
|
|
||||||
//scales the position so the collision geomentry is in the right place
|
|
||||||
rigidWorldPos = rigidWorldPos * dynamicObjData->scale;
|
|
||||||
|
|
||||||
//offset the rigidRotation from modelspace to worldspace;
|
|
||||||
rigidWorldRotation = (Oyster::Math::Float4)dynamicObjData->rotation + (Oyster::Math::Float4)dynamicObjData->boundingVolume.box.rotation;
|
|
||||||
|
|
||||||
//mass scaled
|
|
||||||
rigidBodyMass = dynamicObjData->scale[0] * dynamicObjData->scale[1] * dynamicObjData->scale[2] * dynamicObjData->boundingVolume.box.mass;
|
|
||||||
|
|
||||||
//size scaled
|
|
||||||
rigidBodySize = (Oyster::Math::Float3)dynamicObjData->boundingVolume.box.size * (Oyster::Math::Float3)dynamicObjData->scale;
|
|
||||||
|
|
||||||
//create the rigid body
|
|
||||||
rigidBody_Dynamic = API::Instance().AddCollisionBox(rigidBodySize , rigidWorldRotation , rigidWorldPos , rigidBodyMass, dynamicObjData->boundingVolume.box.restitutionCoeff , dynamicObjData->boundingVolume.box.frictionCoeffStatic , dynamicObjData->boundingVolume.box.frictionCoeffDynamic);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(dynamicObjData->boundingVolume.geoType == CollisionGeometryType_Cylinder)
|
else if(dynamicObjData->boundingVolume.geoType == CollisionGeometryType_Cylinder)
|
||||||
{
|
{
|
||||||
|
//rigidBody_Dynamic = InitRigidBodyCylinder(dynamicObjData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// add rigidbody to the logical obj
|
|
||||||
// Object::DefaultCollisionBefore, Object::DefaultCollisionAfter for now, gamelogic will take care of this
|
|
||||||
// set object_type to objID
|
|
||||||
if(rigidBody_Dynamic != NULL)
|
if(rigidBody_Dynamic != NULL)
|
||||||
{
|
{
|
||||||
this->dynamicObjects.Push(new DynamicObject(rigidBody_Dynamic , Object::DefaultCollisionAfter, (ObjectSpecialType)dynamicObjData->specialTypeID));
|
// create game object
|
||||||
this->dynamicObjects[dynamicObjCount]->objectID = modelCount++;
|
Object* dynamicGameObj = createGameObj(dynamicObjData, rigidBody_Dynamic);
|
||||||
rigidBody_Dynamic->SetCustomTag(this->dynamicObjects[dynamicObjCount]);
|
if (dynamicGameObj != NULL)
|
||||||
|
{
|
||||||
|
this->dynamicObjects.Push((DynamicObject*)dynamicGameObj);
|
||||||
|
this->dynamicObjects[this->dynamicObjects.Size()-1]->objectID = modelCount++;
|
||||||
|
rigidBody_Dynamic->SetCustomTag(this->dynamicObjects[this->dynamicObjects.Size()-1]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,9 +32,10 @@ namespace GameLogic
|
||||||
********************************************************/
|
********************************************************/
|
||||||
void InitiateLevel(std::string levelPath);
|
void InitiateLevel(std::string levelPath);
|
||||||
void InitiateLevel(float radius);
|
void InitiateLevel(float radius);
|
||||||
|
Oyster::Physics::ICustomBody* InitRigidBodyCube( const ObjectHeader* obj);
|
||||||
|
Oyster::Physics::ICustomBody* InitRigidBodySphere( const ObjectHeader* obj);
|
||||||
|
|
||||||
void parseObjectType(ObjectTypeHeader* obj);
|
Object* createGameObj(ObjectHeader* obj, Oyster::Physics::ICustomBody* rigidBody);
|
||||||
void parsePhysicsObj(LevelLoaderInternal::BoundingVolumeBase* obj);
|
|
||||||
/********************************************************
|
/********************************************************
|
||||||
* Creates a team in the level
|
* Creates a team in the level
|
||||||
* @param teamSize: The size of the team you want to create
|
* @param teamSize: The size of the team you want to create
|
||||||
|
|
|
@ -149,7 +149,7 @@ namespace GameLogic
|
||||||
//Läs in filen.
|
//Läs in filen.
|
||||||
int fileLength = 0;
|
int fileLength = 0;
|
||||||
Loader loader;
|
Loader loader;
|
||||||
char* buf = loader.LoadFile("C:/Users/Sam/Documents/GitHub/Danbias/Bin/Content/worlds/cgf/"+ fileName, fileLength);
|
char* buf = loader.LoadFile("../Content/Worlds/cgf/"+ fileName, fileLength);
|
||||||
|
|
||||||
start = 0;
|
start = 0;
|
||||||
LevelLoaderInternal::FormatVersion version;
|
LevelLoaderInternal::FormatVersion version;
|
||||||
|
|
|
@ -9,7 +9,7 @@ Portal::Portal(void)
|
||||||
this->portalExit = Float3(0,0,0);
|
this->portalExit = Float3(0,0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Portal::Portal(Oyster::Physics::ICustomBody *rigidBody, void (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type, Oyster::Math::Float3 portalExit)
|
Portal::Portal(Oyster::Physics::ICustomBody *rigidBody, void (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, Oyster::Math::Float3 portalExit)
|
||||||
:StaticObject(rigidBody, collisionFuncAfter, type)
|
:StaticObject(rigidBody, collisionFuncAfter, type)
|
||||||
{
|
{
|
||||||
this->portalExit = portalExit;
|
this->portalExit = portalExit;
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace GameLogic
|
||||||
|
|
||||||
Portal(Oyster::Physics::ICustomBody *rigidBody
|
Portal(Oyster::Physics::ICustomBody *rigidBody
|
||||||
,void (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss)
|
,void (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss)
|
||||||
,OBJECT_TYPE type, Oyster::Math::Float3 portalExit);
|
,ObjectSpecialType type, Oyster::Math::Float3 portalExit);
|
||||||
|
|
||||||
~Portal(void);
|
~Portal(void);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue