Merge remote-tracking branch 'origin/GameLogic' into Camera-Merge-buffer
Conflicts: Code/Game/DanBiasGame/GameClientState/GameState.cpp Code/Game/DanBiasGame/GameClientState/LoginState.cpp
This commit is contained in:
commit
66d4fcef3a
|
@ -83,15 +83,15 @@ namespace DanBias
|
|||
|
||||
if(EventButton<Owner>::GetState() == ButtonState_None)
|
||||
{
|
||||
Oyster::Graphics::API::RenderGuiElement(texture, pos.xy, size, Oyster::Math::Float3(1.0f, 1.0f, 1.0f));
|
||||
//Oyster::Graphics::API::RenderGuiElement(texture, pos.xy, size, Oyster::Math::Float3(1.0f, 1.0f, 1.0f));
|
||||
}
|
||||
else if(EventButton<Owner>::GetState() == ButtonState_Hover)
|
||||
{
|
||||
Oyster::Graphics::API::RenderGuiElement(texture, pos.xy, size, Oyster::Math::Float3(0.0f, 1.0f, 0.0f));
|
||||
//Oyster::Graphics::API::RenderGuiElement(texture, pos.xy, size, Oyster::Math::Float3(0.0f, 1.0f, 0.0f));
|
||||
}
|
||||
else
|
||||
{
|
||||
Oyster::Graphics::API::RenderGuiElement(texture, pos.xy, size, Oyster::Math::Float3(1.0f, 0.0f, 0.0f));
|
||||
//Oyster::Graphics::API::RenderGuiElement(texture, pos.xy, size, Oyster::Math::Float3(1.0f, 0.0f, 0.0f));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ namespace DanBias
|
|||
{
|
||||
if(buttonText.size() > 0)
|
||||
{
|
||||
Oyster::Graphics::API::RenderText(buttonText, pos.xy, size, textColor);
|
||||
//Oyster::Graphics::API::RenderText(buttonText, pos.xy, size, textColor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ void AttatchmentMassDriver::Update(float dt)
|
|||
Oyster::Math::Float3 ownerPos = owner->GetPosition();
|
||||
Oyster::Physics::ICustomBody::State ownerState = owner->GetRigidBody()->GetState();
|
||||
Oyster::Math::Float3 up = -ownerState.GetOrientation().v[2];
|
||||
up *= -0.3;
|
||||
up *= -0.3f;
|
||||
Oyster::Math::Float3 pos = ownerPos + (owner->GetLookDir().GetNormalized()*5);
|
||||
|
||||
//state.centerPos = pos;
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include "CollisionManager.h"
|
||||
#include "JumpPad.h"
|
||||
#include "Portal.h"
|
||||
#include "CrystalFormation.h"
|
||||
#include "ExplosiveCrate.h"
|
||||
|
||||
using namespace Oyster;
|
||||
|
@ -47,7 +46,7 @@ using namespace GameLogic;
|
|||
break;
|
||||
|
||||
case ObjectSpecialType::ObjectSpecialType_CrystalFormation:
|
||||
PlayerVLethalObject(*player,*realObj, kineticEnergyLoss,((CrystalFormation*)realObj)->getShreddingDamage());
|
||||
PlayerVLethalObject(*player,*realObj, kineticEnergyLoss,realObj->getExtraDamageOnCollision());
|
||||
//player->playerState = PLAYER_STATE::PLAYER_STATE_WALKING;
|
||||
break;
|
||||
}
|
||||
|
@ -97,7 +96,6 @@ using namespace GameLogic;
|
|||
int forceThreashHold = 200000; //how much force for the box to explode of the impact
|
||||
|
||||
|
||||
|
||||
if(kineticEnergyLoss > forceThreashHold)
|
||||
{
|
||||
ExplosiveCrate* crate = ((ExplosiveCrate*)rigidBodyCrate->GetCustomTag());
|
||||
|
@ -117,16 +115,19 @@ using namespace GameLogic;
|
|||
Object *realObj = (Object*)obj->GetCustomTag();
|
||||
ExplosiveCrate* ExplosionSource = ((ExplosiveCrate*)args);
|
||||
|
||||
|
||||
Oyster::Math::Float3 explosionCenterPos = ExplosionSource->GetPosition();
|
||||
Oyster::Math::Float3 hitObjectPos = obj->GetState().centerPos;
|
||||
Oyster::Math::Float3 force = (((hitObjectPos- explosionCenterPos).GetNormalized()) * ExplosionSource->pushForceMagnitude);
|
||||
|
||||
if(realObj->GetObjectType() == ObjectSpecialType::ObjectSpecialType_Player)
|
||||
{
|
||||
Player *hitPlayer = (Player*)realObj;
|
||||
|
||||
hitPlayer->DamageLife(ExplosionSource->shreddingDamage);
|
||||
hitPlayer->DamageLife(ExplosionSource->getExtraDamageOnCollision());
|
||||
//do shredding damage
|
||||
}
|
||||
|
||||
realObj->GetRigidBody()->ApplyImpulse(ExplosionSource->pushForce);
|
||||
realObj->GetRigidBody()->ApplyImpulse(force);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
#include "CrystalFormation.h"
|
||||
|
||||
using namespace GameLogic;
|
||||
|
||||
CrystalFormation::CrystalFormation(void)
|
||||
:StaticObject()
|
||||
{
|
||||
this->shreddingDamage = 0;
|
||||
}
|
||||
|
||||
CrystalFormation::CrystalFormation(Oyster::Physics::ICustomBody *rigidBody, int objectID,Oyster::Math::Float shreddingDamage)
|
||||
:StaticObject(rigidBody, CrystalFormation::DefaultCollisionAfter, ObjectSpecialType::ObjectSpecialType_CrystalFormation, objectID)
|
||||
{
|
||||
this->shreddingDamage = shreddingDamage;
|
||||
}
|
||||
|
||||
|
||||
CrystalFormation::~CrystalFormation(void)
|
||||
{
|
||||
}
|
||||
|
||||
Oyster::Math::Float CrystalFormation::getShreddingDamage()
|
||||
{
|
||||
return this->shreddingDamage;
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
#ifndef CRYSTALFORMATION_H
|
||||
#define CRYSTALFORMATION_H
|
||||
#include "StaticObject.h"
|
||||
namespace GameLogic
|
||||
{
|
||||
class CrystalFormation : public StaticObject
|
||||
{
|
||||
public:
|
||||
CrystalFormation(void);
|
||||
|
||||
CrystalFormation(Oyster::Physics::ICustomBody *rigidBody
|
||||
,int objectID,Oyster::Math::Float shreddingDamage);
|
||||
|
||||
~CrystalFormation(void);
|
||||
|
||||
Oyster::Math::Float getShreddingDamage();
|
||||
|
||||
private:
|
||||
Oyster::Math::Float shreddingDamage;
|
||||
};
|
||||
}
|
||||
#endif
|
|
@ -21,6 +21,17 @@ DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::P
|
|||
|
||||
}
|
||||
|
||||
DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody , void (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID, Oyster::Math::Float extraDamageOnCollision)
|
||||
:Object(rigidBody, EventOnCollision, type, objectID)
|
||||
{
|
||||
this->extraDamageOnCollision = extraDamageOnCollision;
|
||||
}
|
||||
|
||||
DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID, Oyster::Math::Float extraDamageOnCollision)
|
||||
:Object(rigidBody, EventOnCollision, type, objectID)
|
||||
{
|
||||
this->extraDamageOnCollision = extraDamageOnCollision;
|
||||
}
|
||||
DynamicObject::~DynamicObject(void)
|
||||
{
|
||||
|
||||
|
|
|
@ -14,9 +14,11 @@ namespace GameLogic
|
|||
|
||||
public:
|
||||
DynamicObject();
|
||||
DynamicObject(Oyster::Physics::ICustomBody *rigidBody , void (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID);
|
||||
DynamicObject(Oyster::Physics::ICustomBody *rigidBody , void (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID);
|
||||
DynamicObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID);
|
||||
|
||||
DynamicObject(Oyster::Physics::ICustomBody *rigidBody , void (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID, Oyster::Math::Float extraDamageOnCollision);
|
||||
DynamicObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID, Oyster::Math::Float extraDamageOnCollision);
|
||||
|
||||
~DynamicObject(void);
|
||||
|
||||
|
|
|
@ -5,16 +5,15 @@ using namespace GameLogic;
|
|||
ExplosiveCrate::ExplosiveCrate(void)
|
||||
:DynamicObject()
|
||||
{
|
||||
this->shreddingDamage = 0;
|
||||
this->pushForce = 0;
|
||||
this->pushForceMagnitude = 0;
|
||||
this->ExplosionRadius = 0;
|
||||
}
|
||||
|
||||
ExplosiveCrate::ExplosiveCrate(Oyster::Physics::ICustomBody *rigidBody,ObjectSpecialType type, int objectID,Oyster::Math::Float shreddingDamage, Oyster::Math::Float3 pushForce, Oyster::Math::Float ExplosionRadius)
|
||||
ExplosiveCrate::ExplosiveCrate(Oyster::Physics::ICustomBody *rigidBody,ObjectSpecialType type, int objectID,Oyster::Math::Float extraDamageOnCollision, Oyster::Math::Float pushForceMagnitude, Oyster::Math::Float ExplosionRadius)
|
||||
:DynamicObject(rigidBody,ExplosiveCrate::ExplosiveCrateCollision, type, objectID)
|
||||
{
|
||||
this->shreddingDamage = shreddingDamage;
|
||||
this->pushForce = pushForce;
|
||||
this->extraDamageOnCollision = extraDamageOnCollision;
|
||||
this->pushForceMagnitude = pushForceMagnitude;
|
||||
this->ExplosionRadius = ExplosionRadius;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace GameLogic
|
|||
public:
|
||||
ExplosiveCrate(void);
|
||||
|
||||
ExplosiveCrate(Oyster::Physics::ICustomBody *rigidBody,ObjectSpecialType type,int objectID,Oyster::Math::Float shreddingDamage, Oyster::Math::Float3 pushForce, Oyster::Math::Float ExplosionRadius);
|
||||
ExplosiveCrate(Oyster::Physics::ICustomBody *rigidBody,ObjectSpecialType type,int objectID,Oyster::Math::Float extraDamageOnCollision, Oyster::Math::Float pushForceMagnitude, Oyster::Math::Float ExplosionRadius);
|
||||
|
||||
~ExplosiveCrate(void);
|
||||
|
||||
|
@ -16,9 +16,10 @@ namespace GameLogic
|
|||
static void Explode(Oyster::Physics::ICustomBody *obj, void* args);
|
||||
|
||||
private:
|
||||
Oyster::Math::Float shreddingDamage;
|
||||
Oyster::Math::Float3 pushForce;
|
||||
Oyster::Math::Float pushForceMagnitude;
|
||||
Oyster::Math::Float ExplosionRadius;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
#endif
|
|
@ -176,7 +176,6 @@
|
|||
<ClInclude Include="AttatchmentMassDriver.h" />
|
||||
<ClInclude Include="AttatchmentSocket.h" />
|
||||
<ClInclude Include="CollisionManager.h" />
|
||||
<ClInclude Include="CrystalFormation.h" />
|
||||
<ClInclude Include="DynamicObject.h" />
|
||||
<ClInclude Include="ExplosiveCrate.h" />
|
||||
<ClInclude Include="Game.h" />
|
||||
|
@ -204,7 +203,6 @@
|
|||
<ClCompile Include="AttatchmentMassDriver.cpp" />
|
||||
<ClCompile Include="AttatchmentSocket.cpp" />
|
||||
<ClCompile Include="CollisionManager.cpp" />
|
||||
<ClCompile Include="CrystalFormation.cpp" />
|
||||
<ClCompile Include="DynamicObject.cpp" />
|
||||
<ClCompile Include="ExplosiveCrate.cpp" />
|
||||
<ClCompile Include="Game.cpp" />
|
||||
|
|
|
@ -43,12 +43,6 @@ namespace GameLogic
|
|||
Oyster::Math::Float3 pushForce;
|
||||
};
|
||||
|
||||
struct ExplosionData
|
||||
{
|
||||
Oyster::Math::Float3 pushForce;
|
||||
Oyster::Math::Float3 ShreddingDamage;
|
||||
};
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
|
|
@ -11,9 +11,9 @@ Game::PlayerData::PlayerData()
|
|||
|
||||
Oyster::Math::Float3 size = Oyster::Math::Float3(0.25f,2.0f,0.5f);
|
||||
Oyster::Math::Float mass = 60;
|
||||
Oyster::Math::Float restitutionCoeff = 0.5;
|
||||
Oyster::Math::Float frictionCoeff_Static = 0.4;
|
||||
Oyster::Math::Float frictionCoeff_Dynamic = 0.3;
|
||||
Oyster::Math::Float restitutionCoeff = 0.5f;
|
||||
Oyster::Math::Float frictionCoeff_Static = 0.4f;
|
||||
Oyster::Math::Float frictionCoeff_Dynamic = 0.3f;
|
||||
//sbDesc.quaternion = Oyster::Math::Float3(0, Oyster::Math::pi, 0);
|
||||
|
||||
//create rigid body
|
||||
|
@ -29,6 +29,7 @@ Game::PlayerData::PlayerData(int playerID,int teamID)
|
|||
{
|
||||
Oyster::Physics::ICustomBody* rigidBody;
|
||||
this->player = new Player();
|
||||
|
||||
}
|
||||
Game::PlayerData::~PlayerData()
|
||||
{
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
#include "Level.h"
|
||||
#include "CollisionManager.h"
|
||||
#include "Game.h"
|
||||
|
||||
#include "JumpPad.h"
|
||||
#include "ExplosiveCrate.h"
|
||||
#include "Portal.h"
|
||||
using namespace GameLogic;
|
||||
using namespace Utility::DynamicMemory;
|
||||
using namespace Oyster::Physics;
|
||||
|
@ -9,7 +11,7 @@ using namespace Oyster::Physics;
|
|||
|
||||
Level::Level(void)
|
||||
{
|
||||
|
||||
objID = 100;
|
||||
}
|
||||
Level::~Level(void)
|
||||
{
|
||||
|
@ -18,18 +20,20 @@ Level::~Level(void)
|
|||
}
|
||||
Object* Level::createGameObj(ObjectHeader* obj, ICustomBody* rigidBody)
|
||||
{
|
||||
Object* gameObj =NULL;
|
||||
Object* gameObj = NULL;
|
||||
|
||||
switch ((ObjectSpecialType)obj->specialTypeID)
|
||||
{
|
||||
case ObjectSpecialType_None:
|
||||
{
|
||||
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID,0);
|
||||
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++);
|
||||
|
||||
}
|
||||
break;
|
||||
case ObjectSpecialType_Sky:
|
||||
{
|
||||
float skySize = ((SkyAttributes*)obj)->skySize;
|
||||
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID,0);
|
||||
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++);
|
||||
}
|
||||
break;
|
||||
case ObjectSpecialType_World:
|
||||
|
@ -39,28 +43,29 @@ Object* Level::createGameObj(ObjectHeader* obj, ICustomBody* rigidBody)
|
|||
|
||||
float worldSize = ((WorldAttributes*)obj)->worldSize;
|
||||
float atmosphereSize = ((WorldAttributes*)obj)->atmoSphereSize;
|
||||
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID,0);
|
||||
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++);
|
||||
}
|
||||
break;
|
||||
case ObjectSpecialType_Building:
|
||||
{
|
||||
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID,0);
|
||||
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++);
|
||||
}
|
||||
case ObjectSpecialType_Stone:
|
||||
{
|
||||
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID,0);
|
||||
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++);
|
||||
}
|
||||
break;
|
||||
case ObjectSpecialType_StandardBox:
|
||||
{
|
||||
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID,0);
|
||||
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++);
|
||||
}
|
||||
break;
|
||||
case ObjectSpecialType_RedExplosiveBox:
|
||||
{
|
||||
int dmg = 50;
|
||||
//gameObj = new ExplosiveBox(rigidBody, ObjectSpecialType_RedExplosiveBox);
|
||||
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID,0);
|
||||
Oyster::Math::Float force = 50;
|
||||
int radie = 50;
|
||||
gameObj = new ExplosiveCrate(rigidBody, (ObjectSpecialType)obj->specialTypeID, objID++, dmg, force, radie);
|
||||
}
|
||||
break;
|
||||
//case ObjectSpecialType_BlueExplosiveBox:
|
||||
|
@ -69,58 +74,60 @@ Object* Level::createGameObj(ObjectHeader* obj, ICustomBody* rigidBody)
|
|||
// break;
|
||||
case ObjectSpecialType_SpikeBox:
|
||||
{
|
||||
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID,0);
|
||||
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++);
|
||||
}
|
||||
break;
|
||||
case ObjectSpecialType_Spike:
|
||||
{
|
||||
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID,0);
|
||||
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++);
|
||||
}
|
||||
break;
|
||||
case ObjectSpecialType_CrystalFormation:
|
||||
{
|
||||
int dmg = 50;
|
||||
//gameObj = new Crystal(rigidBody);
|
||||
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID,0);
|
||||
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++);
|
||||
}
|
||||
break;
|
||||
case ObjectSpecialType_CrystalShard:
|
||||
{
|
||||
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID,0);
|
||||
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++);
|
||||
}
|
||||
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,0);
|
||||
Oyster::Math::Float3 pushForce = dir * power;
|
||||
gameObj = new JumpPad(rigidBody, (ObjectSpecialType)obj->specialTypeID, objID++ , pushForce);
|
||||
}
|
||||
break;
|
||||
case ObjectSpecialType_Portal:
|
||||
{
|
||||
Oyster::Math::Float3 destination = ((PortalAttributes*)obj)->destination;
|
||||
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID,0);
|
||||
gameObj = new Portal(rigidBody, (ObjectSpecialType)obj->specialTypeID, objID++, destination);
|
||||
}
|
||||
break;
|
||||
case ObjectSpecialType_SpawnPoint:
|
||||
{
|
||||
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID,0);
|
||||
// save
|
||||
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++);
|
||||
}
|
||||
break;
|
||||
case ObjectSpecialType_Player:
|
||||
{
|
||||
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID,0);
|
||||
// should not be read from the lvl format
|
||||
//gameObj = new Player(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID,objID++);
|
||||
}
|
||||
break;
|
||||
case ObjectSpecialType_Generic:
|
||||
{
|
||||
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID,0);
|
||||
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID,0);
|
||||
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -137,6 +144,7 @@ ICustomBody* Level::InitRigidBodyCube( const ObjectHeader* obj)
|
|||
|
||||
//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;
|
||||
|
||||
|
@ -182,7 +190,7 @@ ICustomBody* Level::InitRigidBodySphere( const ObjectHeader* obj)
|
|||
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 = (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
|
||||
|
@ -230,7 +238,7 @@ void Level::InitiateLevel(std::string levelPath)
|
|||
else if(staticObjData->boundingVolume.geoType == CollisionGeometryType_Box)
|
||||
{
|
||||
|
||||
rigidBody_Static = InitRigidBodySphere(staticObjData);
|
||||
rigidBody_Static = InitRigidBodyCube(staticObjData);
|
||||
}
|
||||
|
||||
else if(staticObjData->boundingVolume.geoType == CollisionGeometryType_Cylinder)
|
||||
|
@ -240,7 +248,18 @@ void Level::InitiateLevel(std::string levelPath)
|
|||
|
||||
if(rigidBody_Static != NULL)
|
||||
{
|
||||
this->staticObjects.Push(new StaticObject(rigidBody_Static, Object::DefaultCollisionAfter, (ObjectSpecialType)staticObjData->specialTypeID, 0));
|
||||
|
||||
// create game object
|
||||
Object* staticGameObj = createGameObj(staticObjData, rigidBody_Static);
|
||||
//Object* staticGameObj = new StaticObject(rigidBody_Static, Object::DefaultCollisionAfter, (ObjectSpecialType)staticObjData->specialTypeID);
|
||||
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]);
|
||||
}
|
||||
|
||||
//this->staticObjects.Push(new StaticObject(rigidBody_Static, Object::DefaultCollisionAfter, (ObjectSpecialType)staticObjData->specialTypeID, 0));
|
||||
//this->staticObjects[staticObjCount]->objectID = modelCount++;
|
||||
|
||||
}
|
||||
|
@ -272,11 +291,16 @@ void Level::InitiateLevel(std::string levelPath)
|
|||
|
||||
if(rigidBody_Dynamic != NULL)
|
||||
{
|
||||
|
||||
this->dynamicObjects.Push(new DynamicObject(rigidBody_Dynamic , Object::DefaultCollisionAfter, (ObjectSpecialType)dynamicObjData->specialTypeID, 0));
|
||||
//this->dynamicObjects[dynamicObjCount]->objectID = modelCount++;
|
||||
// create game object
|
||||
Object* dynamicGameObj = createGameObj(dynamicObjData, rigidBody_Dynamic);
|
||||
//Object* dynamicGameObj =new DynamicObject(rigidBody_Dynamic, Object::DefaultCollisionAfter, (ObjectSpecialType)dynamicObjData->specialTypeID);
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case ObjectType::ObjectType_Light:
|
||||
|
@ -361,7 +385,7 @@ void Level::InitiateLevel(float radius)
|
|||
//this->staticObjects[0]->objectID = idCount++;
|
||||
|
||||
// add jumppad
|
||||
ICustomBody* rigidBody_Jumppad = API::Instance().AddCollisionBox(Oyster::Math::Float3(1, 1, 1), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(4, 600.3, 0), 5, 0.5f, 0.8f, 0.6f);
|
||||
ICustomBody* rigidBody_Jumppad = API::Instance().AddCollisionBox(Oyster::Math::Float3(1, 1, 1), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(4, 600.3, 0), 0, 0.5f, 0.8f, 0.6f);
|
||||
|
||||
this->staticObjects.Push(new JumpPad(rigidBody_Jumppad, ObjectSpecialType_JumpPad,idCount++ ,Oyster::Math::Float3(0,2000,0)));
|
||||
rigidBody_Jumppad->SetCustomTag(this->staticObjects[1]);
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "StaticObject.h"
|
||||
#include "DynamicObject.h"
|
||||
#include "GameModeType.h"
|
||||
#include "JumpPad.h"
|
||||
|
||||
#include "Player.h"
|
||||
#include "PhysicsAPI.h"
|
||||
#include "TeamManager.h"
|
||||
|
@ -76,6 +76,7 @@ namespace GameLogic
|
|||
GameModeType gameMode;
|
||||
Utility::DynamicMemory::SmartPointer<Oyster::Physics::ICustomBody> rigidBodyLevel;
|
||||
StaticObject *levelObj;
|
||||
int objID;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ Object::Object(Oyster::Physics::ICustomBody *rigidBody, void (*collisionFuncAfte
|
|||
this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_AfterCollisionResponse)(collisionFuncAfter));
|
||||
this->type = type;
|
||||
this->objectID = objectID;
|
||||
this->extraDamageOnCollision = 0;
|
||||
this->rigidBody->SetCustomTag(this);
|
||||
}
|
||||
|
||||
|
@ -38,6 +39,7 @@ Object::Object(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICusto
|
|||
this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_AfterCollisionResponse)(collisionFuncAfter));
|
||||
this->type = type;
|
||||
this->objectID = objectID;
|
||||
this->extraDamageOnCollision = 0;
|
||||
this->rigidBody->SetCustomTag(this);
|
||||
}
|
||||
|
||||
|
@ -103,4 +105,10 @@ Oyster::Math::Float4x4 Object::GetOrientation()
|
|||
Oyster::Physics::ICustomBody::State state;
|
||||
state = this->rigidBody->GetState();
|
||||
return state.GetOrientation();
|
||||
}
|
||||
|
||||
|
||||
Oyster::Math::Float Object::getExtraDamageOnCollision()
|
||||
{
|
||||
return this->extraDamageOnCollision;
|
||||
}
|
|
@ -31,6 +31,8 @@ namespace GameLogic
|
|||
Oyster::Math::Float3 GetScale() override;
|
||||
Oyster::Math::Float4x4 GetOrientation() override;
|
||||
|
||||
Oyster::Math::Float getExtraDamageOnCollision();
|
||||
|
||||
// API overrides
|
||||
|
||||
|
||||
|
@ -58,6 +60,8 @@ namespace GameLogic
|
|||
|
||||
ObjectSpecialType type;
|
||||
int objectID;
|
||||
|
||||
Oyster::Math::Float extraDamageOnCollision;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
using namespace GameLogic;
|
||||
using namespace Oyster::Physics;
|
||||
const int MOVE_FORCE = 30;
|
||||
const float MOVE_FORCE = 30;
|
||||
const float KEY_TIMER = 0.03f;
|
||||
Player::Player()
|
||||
:DynamicObject()
|
||||
|
@ -53,11 +53,15 @@ Player::Player(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustom
|
|||
this->teamID = teamID;
|
||||
this->playerState = PLAYER_STATE_IDLE;
|
||||
this->lookDir = Oyster::Math::Float3(0,0,-1);
|
||||
this->moveDir = Oyster::Math::Float3(0,0,0);
|
||||
key_forward = 0;
|
||||
key_backward = 0;
|
||||
key_strafeRight = 0;
|
||||
key_strafeLeft = 0;
|
||||
|
||||
this->moveDir = Oyster::Math::Float3(0,0,0);
|
||||
this->moveSpeed = 100;
|
||||
this->previousMoveSpeed = Oyster::Math::Float3(0,0,0);
|
||||
|
||||
}
|
||||
|
||||
Player::~Player(void)
|
||||
|
@ -73,48 +77,60 @@ void Player::BeginFrame()
|
|||
{
|
||||
//weapon->Update(0.002f);
|
||||
Object::BeginFrame();
|
||||
Oyster::Math::Float3 forward(0,0,0);
|
||||
Oyster::Math::Float3 back(0,0,0);
|
||||
Oyster::Math::Float3 right(0,0,0);
|
||||
Oyster::Math::Float3 left(0,0,0);
|
||||
Oyster::Math::Float3 moveDirection(0,0,0);
|
||||
|
||||
if(this->moveDir != Oyster::Math::Float3::null)
|
||||
{
|
||||
Oyster::Math::Float3 velocity = this->rigidBody->GetLinearVelocity();
|
||||
Oyster::Math::Float3 lostVelocity = (this->previousMoveSpeed - velocity).GetMagnitude()*this->moveDir;
|
||||
this->rigidBody->SetLinearVelocity(velocity + lostVelocity - this->moveDir*this->moveSpeed );
|
||||
}
|
||||
|
||||
this->moveDir = Oyster::Math::Float3::null;
|
||||
|
||||
if (key_forward > 0.001)
|
||||
{
|
||||
key_forward -= gameInstance->GetFrameTime(); // fixed timer
|
||||
forward = this->rigidBody->GetState().GetOrientation().v[2].GetNormalized();
|
||||
this->moveDir += this->rigidBody->GetState().GetOrientation().v[2].GetNormalized().xyz;
|
||||
}
|
||||
if (key_backward > 0.001)
|
||||
{
|
||||
key_backward -= gameInstance->GetFrameTime();
|
||||
back = -this->rigidBody->GetState().GetOrientation().v[2].GetNormalized();
|
||||
this->moveDir -= this->rigidBody->GetState().GetOrientation().v[2].GetNormalized().xyz;
|
||||
}
|
||||
if (key_strafeRight > 0.001)
|
||||
{
|
||||
|
||||
key_strafeRight -= gameInstance->GetFrameTime();
|
||||
Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2].GetNormalized();
|
||||
Oyster::Math::Float3 up = this->rigidBody->GetState().centerPos.Normalize();
|
||||
right = -((up).Cross(forward).Normalize());
|
||||
right.Normalize();
|
||||
Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2];
|
||||
Oyster::Math::Float3 up = this->rigidBody->GetState().centerPos;
|
||||
this->moveDir -= (up).Cross(forward).GetNormalized();
|
||||
}
|
||||
if (key_strafeLeft > 0.001)
|
||||
{
|
||||
key_strafeLeft -= gameInstance->GetFrameTime();
|
||||
Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2].GetNormalized();
|
||||
Oyster::Math::Float3 up = this->rigidBody->GetState().centerPos.Normalize();
|
||||
left = (up).Cross(forward).Normalize();
|
||||
left.Normalize();
|
||||
Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2];
|
||||
Oyster::Math::Float3 up = this->rigidBody->GetState().centerPos;
|
||||
this->moveDir += (up).Cross(forward).GetNormalized();
|
||||
}
|
||||
moveDirection = forward + back + left + right;
|
||||
//moveDirection.Normalize();
|
||||
rigidBody->SetLinearVelocity( MOVE_FORCE * moveDirection );
|
||||
|
||||
weapon->Update(0.01f);
|
||||
if(this->moveDir != Oyster::Math::Float3::null)
|
||||
{
|
||||
this->moveDir.Normalize();
|
||||
this->rigidBody->SetLinearVelocity(this->moveDir*this->moveSpeed + this->rigidBody->GetLinearVelocity());
|
||||
this->previousMoveSpeed = this->rigidBody->GetLinearVelocity();
|
||||
}
|
||||
|
||||
|
||||
this->weapon->Update(0.01f);
|
||||
}
|
||||
|
||||
void Player::EndFrame()
|
||||
{
|
||||
// snap to axis
|
||||
Oyster::Math::Float4 rotation;
|
||||
|
||||
this->rigidBody->SetUp(this->rigidBody->GetState().centerPos.GetNormalized());
|
||||
|
||||
|
||||
Object::EndFrame();
|
||||
}
|
||||
|
||||
|
@ -167,8 +183,7 @@ void Player::UseWeapon(const WEAPON_FIRE &usage)
|
|||
}
|
||||
|
||||
void Player::Respawn(Oyster::Math::Float3 spawnPoint)
|
||||
{
|
||||
key_jump =
|
||||
{
|
||||
this->life = 100;
|
||||
this->playerState = PLAYER_STATE::PLAYER_STATE_IDLE;
|
||||
this->lookDir = Oyster::Math::Float4(1,0,0);
|
||||
|
@ -182,14 +197,13 @@ void Player::Rotate(const Oyster::Math3D::Float3 lookDir, const Oyster::Math3D::
|
|||
|
||||
Oyster::Math::Float3 up = this->rigidBody->GetState().GetOrientation().v[1];
|
||||
this->rigidBody->SetUpAndRight(up, right);
|
||||
this->rigidBody->SetUpAndRight(this->rigidBody->GetState().centerPos.GetNormalized(), this->rigidBody->GetState().GetOrientation().v[0].xyz.GetNormalized());
|
||||
}
|
||||
|
||||
void Player::Jump()
|
||||
{
|
||||
Oyster::Math::Float3 up = this->rigidBody->GetState().GetOrientation().v[1].GetNormalized();
|
||||
this->rigidBody->ApplyImpulse(up *1500);
|
||||
this->playerState == PLAYER_STATE::PLAYER_STATE_JUMPING;
|
||||
this->playerState = PLAYER_STATE::PLAYER_STATE_JUMPING;
|
||||
}
|
||||
|
||||
bool Player::IsWalking()
|
||||
|
@ -238,4 +252,3 @@ void Player::DamageLife(int damage)
|
|||
this->gameInstance->onDisableFnc(this, 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,6 @@ namespace GameLogic
|
|||
void EndFrame();
|
||||
static Oyster::Physics::ICustomBody::SubscriptMessage PlayerCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss);
|
||||
|
||||
|
||||
private:
|
||||
void Jump();
|
||||
|
||||
|
@ -82,7 +81,6 @@ namespace GameLogic
|
|||
int teamID;
|
||||
Weapon *weapon;
|
||||
PLAYER_STATE playerState;
|
||||
Oyster::Math::Float3 moveDir;
|
||||
Oyster::Math::Float3 lookDir;
|
||||
float key_forward;
|
||||
float key_backward;
|
||||
|
@ -90,9 +88,14 @@ namespace GameLogic
|
|||
float key_strafeLeft;
|
||||
float key_jump;
|
||||
|
||||
|
||||
Oyster::Math::Float3 moveDir;
|
||||
Oyster::Math::Float moveSpeed;
|
||||
Oyster::Math::Float3 previousMoveSpeed;
|
||||
|
||||
|
||||
bool hasTakenDamage;
|
||||
float invincibleCooldown;
|
||||
|
||||
};
|
||||
}
|
||||
#endif
|
|
@ -10,8 +10,8 @@ Portal::Portal(void)
|
|||
}
|
||||
|
||||
|
||||
Portal::Portal(Oyster::Physics::ICustomBody *rigidBody, void (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type,int objectID ,Oyster::Math::Float3 portalExit)
|
||||
:StaticObject(rigidBody, EventOnCollision, type, objectID)
|
||||
Portal::Portal(Oyster::Physics::ICustomBody *rigidBody, ObjectSpecialType type,int objectID ,Oyster::Math::Float3 portalExit)
|
||||
:StaticObject(rigidBody, Portal::PortalActivated, type, objectID)
|
||||
{
|
||||
this->portalExit = portalExit;
|
||||
}
|
||||
|
|
|
@ -8,8 +8,7 @@ namespace GameLogic
|
|||
public:
|
||||
Portal(void);
|
||||
|
||||
Portal(Oyster::Physics::ICustomBody *rigidBody
|
||||
,void (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss)
|
||||
Portal(Oyster::Physics::ICustomBody *rigidBody
|
||||
,ObjectSpecialType type,int objectID ,Oyster::Math::Float3 portalExit);
|
||||
|
||||
~Portal(void);
|
||||
|
|
|
@ -23,6 +23,17 @@ StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::Phy
|
|||
//use setMass(when it is made) and set the mass to 0 in order to ensure that the object is static
|
||||
}
|
||||
|
||||
StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody , void (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID, Oyster::Math::Float extraDamageOnCollision)
|
||||
{
|
||||
this->extraDamageOnCollision = extraDamageOnCollision;
|
||||
//use setMass(when it is made) and set the mass to 0 in order to ensure that the object is static
|
||||
}
|
||||
|
||||
StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID, Oyster::Math::Float extraDamageOnCollision)
|
||||
{
|
||||
this->extraDamageOnCollision = extraDamageOnCollision;
|
||||
//use setMass(when it is made) and set the mass to 0 in order to ensure that the object is static
|
||||
}
|
||||
StaticObject::~StaticObject(void)
|
||||
{
|
||||
|
||||
|
|
|
@ -21,6 +21,9 @@ namespace GameLogic
|
|||
StaticObject(Oyster::Physics::ICustomBody *rigidBody , void (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID);
|
||||
StaticObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID);
|
||||
|
||||
StaticObject(Oyster::Physics::ICustomBody *rigidBody , void (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID, Oyster::Math::Float extraDamageOnCollision);
|
||||
StaticObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID, Oyster::Math::Float extraDamageOnCollision);
|
||||
|
||||
~StaticObject(void);
|
||||
|
||||
private:
|
||||
|
|
|
@ -165,22 +165,16 @@
|
|||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Implementation\Octree.h" />
|
||||
<ClInclude Include="Implementation\PhysicsAPI_Impl.h" />
|
||||
<ClInclude Include="Implementation\SimpleRigidBody.h" />
|
||||
<ClInclude Include="Implementation\SphericalRigidBody.h" />
|
||||
<ClInclude Include="PhysicsAPI.h" />
|
||||
<ClInclude Include="PhysicsFormula-Impl.h" />
|
||||
<ClInclude Include="PhysicsFormula.h" />
|
||||
<ClInclude Include="PhysicsStructs-Impl.h" />
|
||||
<ClInclude Include="PhysicsStructs.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Implementation\Octree.cpp" />
|
||||
<ClCompile Include="Implementation\DLLMain.cpp" />
|
||||
<ClCompile Include="Implementation\PhysicsAPI_Impl.cpp" />
|
||||
<ClCompile Include="Implementation\SimpleRigidBody.cpp" />
|
||||
<ClCompile Include="Implementation\SphericalRigidBody.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
|
|
@ -30,24 +30,12 @@
|
|||
<ClInclude Include="Implementation\SimpleRigidBody.h">
|
||||
<Filter>Header Files\Implementation</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Implementation\SphericalRigidBody.h">
|
||||
<Filter>Header Files\Implementation</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Implementation\Octree.h">
|
||||
<Filter>Header Files\Implementation</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="PhysicsStructs.h">
|
||||
<Filter>Header Files\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="PhysicsStructs-Impl.h">
|
||||
<Filter>Header Files\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="PhysicsFormula.h">
|
||||
<Filter>Header Files\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="PhysicsFormula-Impl.h">
|
||||
<Filter>Header Files\Include</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Implementation\PhysicsAPI_Impl.cpp">
|
||||
|
@ -59,11 +47,5 @@
|
|||
<ClCompile Include="Implementation\DLLMain.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Implementation\SphericalRigidBody.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Implementation\Octree.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -1,226 +0,0 @@
|
|||
#include "Octree.h"
|
||||
|
||||
using namespace Oyster;
|
||||
using namespace Physics;
|
||||
using namespace ::Utility::DynamicMemory;
|
||||
|
||||
const unsigned int Octree::invalid_ref = ::Utility::Value::numeric_limits<unsigned int>::max();
|
||||
|
||||
Octree::Octree(unsigned int bufferSize, unsigned char numLayers, Math::Float3 worldSize)
|
||||
{
|
||||
this->worldNode.dataPtr = NULL;
|
||||
|
||||
this->worldNode.container.maxVertex = worldSize*0.5f;
|
||||
this->worldNode.container.minVertex = -worldSize*0.5f;
|
||||
}
|
||||
|
||||
Octree::~Octree()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Octree& Octree::operator=(const Octree& orig)
|
||||
{
|
||||
this->leafData = orig.leafData;
|
||||
this->updateQueue = orig.updateQueue;
|
||||
this->worldNode = orig.worldNode;
|
||||
this->mapReferences = orig.mapReferences;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Octree::AddObject(UniquePointer< ICustomBody > customBodyRef)
|
||||
{
|
||||
//customBodyRef->SetScene( this );
|
||||
Data data;
|
||||
//Data* tempPtr = this->worldNode.dataPtr;
|
||||
|
||||
//data.container = customBodyRef->GetBoundingSphere();
|
||||
data.queueRef = -1;
|
||||
data.next = NULL;
|
||||
data.prev = NULL;
|
||||
data.customBodyRef = customBodyRef;
|
||||
data.limbo = false;
|
||||
this->mapReferences.insert(std::pair <ICustomBody*, unsigned int> (data.customBodyRef, this->leafData.size()));
|
||||
this->leafData.push_back(data);
|
||||
|
||||
/*if(tempPtr != NULL)
|
||||
{
|
||||
tempPtr->prev->next = &this->leafData[this->leafData.size() - 1];
|
||||
this->leafData[this->leafData.size() - 1].prev = tempPtr->prev;
|
||||
tempPtr->prev = &this->leafData[this->leafData.size() - 1];
|
||||
this->leafData[this->leafData.size() - 1].next = tempPtr;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->worldNode.dataPtr = &this->leafData[this->leafData.size() - 1];
|
||||
this->worldNode.dataPtr->next = this->worldNode.dataPtr;
|
||||
this->worldNode.dataPtr->prev = this->worldNode.dataPtr;
|
||||
}*/
|
||||
}
|
||||
|
||||
void Octree::MoveToUpdateQueue(UniquePointer< ICustomBody > customBodyRef)
|
||||
{
|
||||
/*this->leafData[this->mapReferences[customBodyRef]].queueRef = this->updateQueue.size();
|
||||
this->updateQueue.push_back(&this->leafData[this->mapReferences[customBodyRef]]);*/
|
||||
}
|
||||
|
||||
void Octree::MoveToLimbo(const ICustomBody* customBodyRef)
|
||||
{
|
||||
auto object = this->mapReferences.find(customBodyRef);
|
||||
|
||||
unsigned int tempRef = object->second;
|
||||
|
||||
this->leafData[tempRef].limbo = true;
|
||||
}
|
||||
|
||||
bool Octree::IsInLimbo(const ICustomBody* customBodyRef)
|
||||
{
|
||||
auto object = this->mapReferences.find(customBodyRef);
|
||||
|
||||
unsigned int tempRef = object->second;
|
||||
|
||||
return this->leafData[tempRef].limbo;
|
||||
}
|
||||
|
||||
void Octree::ReleaseFromLimbo(const ICustomBody* customBodyRef)
|
||||
{
|
||||
auto object = this->mapReferences.find(customBodyRef);
|
||||
|
||||
unsigned int tempRef = object->second;
|
||||
|
||||
this->leafData[tempRef].limbo = false;
|
||||
}
|
||||
|
||||
void Octree::DestroyObject(UniquePointer< ICustomBody > customBodyRef)
|
||||
{
|
||||
std::map<const ICustomBody*, unsigned int>::iterator it = this->mapReferences.find(customBodyRef);
|
||||
|
||||
this->mapReferences.erase(it);
|
||||
|
||||
this->leafData.erase(this->leafData.begin() + this->leafData[this->mapReferences[customBodyRef]].queueRef);
|
||||
}
|
||||
|
||||
std::vector<ICustomBody*>& Octree::Sample(ICustomBody* customBodyRef, std::vector<ICustomBody*>& updateList)
|
||||
{
|
||||
auto object = this->mapReferences.find(customBodyRef);
|
||||
|
||||
if(object == this->mapReferences.end())
|
||||
{
|
||||
return updateList;
|
||||
}
|
||||
|
||||
unsigned int tempRef = object->second;
|
||||
|
||||
for(unsigned int i = 0; i<this->leafData.size(); i++)
|
||||
{
|
||||
if(tempRef != i && !this->leafData[i].limbo) if(this->leafData[tempRef].container.Intersects(this->leafData[i].container))
|
||||
{
|
||||
updateList.push_back(this->leafData[i].customBodyRef);
|
||||
}
|
||||
}
|
||||
|
||||
return updateList;
|
||||
}
|
||||
|
||||
std::vector<ICustomBody*>& Octree::Sample(const Oyster::Collision3D::ICollideable& collideable, std::vector<ICustomBody*>& updateList)
|
||||
{
|
||||
for(unsigned int i = 0; i<this->leafData.size(); i++)
|
||||
{
|
||||
if(!this->leafData[i].limbo && this->leafData[i].container.Intersects(collideable))
|
||||
{
|
||||
updateList.push_back(this->leafData[i].customBodyRef);
|
||||
}
|
||||
}
|
||||
|
||||
return updateList;
|
||||
}
|
||||
|
||||
void Octree::Visit(ICustomBody* customBodyRef, VisitorAction hitAction )
|
||||
{
|
||||
auto object = this->mapReferences.find(customBodyRef);
|
||||
|
||||
// If rigid body is not found
|
||||
if(object == this->mapReferences.end())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned int tempRef = object->second;
|
||||
|
||||
// Go through all object and test for intersection
|
||||
for(unsigned int i = 0; i<this->leafData.size(); i++)
|
||||
{
|
||||
// If objects intersect call collision response function
|
||||
if(tempRef != i && !this->leafData[i].limbo) if(this->leafData[tempRef].container.Intersects(this->leafData[i].container))
|
||||
{
|
||||
hitAction(*this, tempRef, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Octree::Visit(const Oyster::Collision3D::ICollideable& collideable, void* args, VisitorActionCollideable hitAction)
|
||||
{
|
||||
for(unsigned int i = 0; i<this->leafData.size(); i++)
|
||||
{
|
||||
if(!this->leafData[i].limbo && collideable.Intersects(this->leafData[i].container))
|
||||
{
|
||||
hitAction( this->GetCustomBody(i), args );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ICustomBody* Octree::GetCustomBody(const unsigned int tempRef)
|
||||
{
|
||||
return this->leafData[tempRef].customBodyRef;
|
||||
}
|
||||
|
||||
UniquePointer<ICustomBody> Octree::Extract( const ICustomBody* objRef )
|
||||
{ // Dan Andersson
|
||||
auto iter = this->mapReferences.find( objRef );
|
||||
if( iter != this->mapReferences.end() )
|
||||
{
|
||||
return this->Extract( iter->second );
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
UniquePointer<ICustomBody> Octree::Extract( unsigned int tempRef )
|
||||
{
|
||||
if( tempRef != Octree::invalid_ref )
|
||||
{
|
||||
//! @todo TODO: implement stub
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int Octree::GetTemporaryReferenceOf( const ICustomBody* objRef ) const
|
||||
{ // Dan Andersson
|
||||
auto iter = this->mapReferences.find( objRef );
|
||||
if( iter != this->mapReferences.end() )
|
||||
{
|
||||
return iter->second;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Octree::invalid_ref;
|
||||
}
|
||||
}
|
||||
|
||||
void Octree::SetAsAltered( unsigned int tempRef )
|
||||
{
|
||||
//this->leafData[tempRef].container = this->leafData[tempRef].customBodyRef->GetBoundingSphere();
|
||||
//! @todo TODO: implement stub
|
||||
}
|
||||
|
||||
void Octree::EvaluatePosition( unsigned int tempRef )
|
||||
{
|
||||
//! @todo TODO: implement stub
|
||||
}
|
|
@ -1,85 +0,0 @@
|
|||
#ifndef OCTREE_H
|
||||
#define OCTREE_H
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include "Sphere.h"
|
||||
#include "BoxAxisAligned.h"
|
||||
#include "Utilities.h"
|
||||
#include "../PhysicsAPI.h"
|
||||
|
||||
namespace Oyster
|
||||
{
|
||||
namespace Physics
|
||||
{
|
||||
class Octree
|
||||
{
|
||||
public:
|
||||
static const unsigned int invalid_ref;
|
||||
|
||||
typedef void(*VisitorAction)(Octree&, unsigned int, unsigned int);
|
||||
typedef void(*VisitorActionCollideable)(ICustomBody*, void*);
|
||||
|
||||
struct Data
|
||||
{
|
||||
Data* prev;
|
||||
Data* next;
|
||||
|
||||
Collision3D::Sphere container;
|
||||
|
||||
::Utility::DynamicMemory::UniquePointer< ICustomBody > customBodyRef;
|
||||
|
||||
bool limbo;
|
||||
|
||||
unsigned int queueRef;
|
||||
};
|
||||
|
||||
struct OctreeNode
|
||||
{
|
||||
OctreeNode* children[8];
|
||||
Data* dataPtr;
|
||||
Collision3D::BoxAxisAligned container;
|
||||
};
|
||||
|
||||
Octree(unsigned int bufferSize = 0, unsigned char numLayers = 0, Math::Float3 worldSize = Math::Float3::null);
|
||||
virtual ~Octree();
|
||||
|
||||
Octree& operator=(const Octree& orig);
|
||||
|
||||
void AddObject(::Utility::DynamicMemory::UniquePointer< ICustomBody > customBodyRef);
|
||||
|
||||
void MoveToUpdateQueue(::Utility::DynamicMemory::UniquePointer< ICustomBody > customBodyRef);
|
||||
|
||||
void MoveToLimbo(const ICustomBody* customBodyRef);
|
||||
bool IsInLimbo(const ICustomBody* customBodyRef);
|
||||
void ReleaseFromLimbo(const ICustomBody* customBodyRef);
|
||||
|
||||
void DestroyObject(::Utility::DynamicMemory::UniquePointer< ICustomBody > customBodyRef);
|
||||
|
||||
std::vector<ICustomBody*>& Sample(ICustomBody* customBodyRef, std::vector<ICustomBody*>& updateList);
|
||||
std::vector<ICustomBody*>& Sample(const Oyster::Collision3D::ICollideable& collideable, std::vector<ICustomBody*>& updateList);
|
||||
void Visit(ICustomBody* customBodyRef, VisitorAction hitAction );
|
||||
void Visit(const Oyster::Collision3D::ICollideable& collideable, void* args, VisitorActionCollideable hitAction );
|
||||
|
||||
ICustomBody* GetCustomBody(const unsigned int tempRef);
|
||||
|
||||
::Utility::DynamicMemory::UniquePointer<ICustomBody> Extract( const ICustomBody* objRef );
|
||||
::Utility::DynamicMemory::UniquePointer<ICustomBody> Extract( unsigned int tempRef ); // Dan vill ha
|
||||
unsigned int GetTemporaryReferenceOf( const ICustomBody* objRef ) const; // Dan vill ha
|
||||
void SetAsAltered( unsigned int tempRef ); // Dan vill ha
|
||||
void EvaluatePosition( unsigned int tempRef ); // Dan vill ha
|
||||
|
||||
private:
|
||||
std::vector < Data > leafData;
|
||||
std::vector < Data* > updateQueue;
|
||||
std::vector < Data* > limbo;
|
||||
|
||||
std::map< const ICustomBody*, unsigned int > mapReferences;
|
||||
|
||||
OctreeNode worldNode;
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,7 +1,6 @@
|
|||
#include "PhysicsAPI_Impl.h"
|
||||
#include "OysterPhysics3D.h"
|
||||
#include "SimpleRigidBody.h"
|
||||
#include "SphericalRigidBody.h"
|
||||
|
||||
using namespace ::Oyster;
|
||||
using namespace ::Oyster::Physics;
|
||||
|
@ -181,6 +180,47 @@ ICustomBody* API_Impl::AddCollisionCylinder(::Oyster::Math::Float3 halfSize, ::O
|
|||
return body;
|
||||
}
|
||||
|
||||
ICustomBody* API_Impl::AddCharacter(::Oyster::Math::Float height, ::Oyster::Math::Float radius, ::Oyster::Math::Float4 rotation, ::Oyster::Math::Float3 position, float mass, float restitution, float staticFriction, float dynamicFriction)
|
||||
{
|
||||
SimpleRigidBody* body = new SimpleRigidBody;
|
||||
SimpleRigidBody::State state;
|
||||
|
||||
// Add collision shape
|
||||
btCapsuleShape* collisionShape = new btCapsuleShape(radius, height);
|
||||
body->SetCollisionShape(collisionShape);
|
||||
|
||||
// Add motion state
|
||||
btDefaultMotionState* motionState = new btDefaultMotionState(btTransform(btQuaternion(rotation.x, rotation.y, rotation.z, rotation.w),btVector3(position.x, position.y, position.z)));
|
||||
body->SetMotionState(motionState);
|
||||
|
||||
// Add rigid body
|
||||
btVector3 fallInertia(0, 0, 0);
|
||||
collisionShape->calculateLocalInertia(mass, fallInertia);
|
||||
btRigidBody::btRigidBodyConstructionInfo rigidBodyCI(mass, motionState, collisionShape, fallInertia);
|
||||
btRigidBody* rigidBody = new btRigidBody(rigidBodyCI);
|
||||
rigidBody->setFriction(staticFriction);
|
||||
rigidBody->setRestitution(restitution);
|
||||
rigidBody->setUserPointer(body);
|
||||
rigidBody->setAngularFactor(0);
|
||||
rigidBody->setSleepingThresholds(0, 0);
|
||||
body->SetRigidBody(rigidBody);
|
||||
|
||||
// Add rigid body to world
|
||||
this->dynamicsWorld->addRigidBody(rigidBody);
|
||||
this->customBodies.push_back(body);
|
||||
|
||||
state.centerPos = position;
|
||||
state.reach = Float3(radius, height*0.5f, radius);
|
||||
state.dynamicFrictionCoeff = 0.5f;
|
||||
state.staticFrictionCoeff = 0.5f;
|
||||
state.quaternion = Quaternion(Float3(rotation.xyz), rotation.w);
|
||||
state.mass = mass;
|
||||
|
||||
body->SetState(state);
|
||||
|
||||
return body;
|
||||
}
|
||||
|
||||
void API_Impl::SetTimeStep(float timeStep)
|
||||
{
|
||||
this->timeStep = timeStep;
|
||||
|
@ -204,11 +244,11 @@ void API_Impl::UpdateWorld()
|
|||
trans = simpleBody->GetRigidBody()->getWorldTransform();
|
||||
this->customBodies[i]->SetPosition(Float3(trans.getOrigin().x(), trans.getOrigin().y(), trans.getOrigin().z()));
|
||||
this->customBodies[i]->SetRotation(Quaternion(Float3(trans.getRotation().x(), trans.getRotation().y(), trans.getRotation().z()), trans.getRotation().w()));
|
||||
|
||||
|
||||
if(simpleBody->GetRigidBody()->getActivationState() == ACTIVE_TAG)
|
||||
{
|
||||
simpleBody->CallSubscription_Move();
|
||||
}
|
||||
this->customBodies[i]->CallSubscription_Move();
|
||||
}
|
||||
}
|
||||
|
||||
int numManifolds = this->dynamicsWorld->getDispatcher()->getNumManifolds();
|
||||
|
@ -221,8 +261,8 @@ void API_Impl::UpdateWorld()
|
|||
ICustomBody* bodyA = (ICustomBody*)obA->getUserPointer();
|
||||
ICustomBody* bodyB = (ICustomBody*)obB->getUserPointer();
|
||||
|
||||
dynamic_cast<SimpleRigidBody*>(bodyA)->CallSubscription_AfterCollisionResponse(bodyA, bodyB, 0.0f);
|
||||
dynamic_cast<SimpleRigidBody*>(bodyB)->CallSubscription_AfterCollisionResponse(bodyB, bodyA, 0.0f);
|
||||
bodyA->CallSubscription_AfterCollisionResponse(bodyA, bodyB, 0.0f);
|
||||
bodyB->CallSubscription_AfterCollisionResponse(bodyB, bodyA, 0.0f);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#define PHYSICS_API_IMPL_H
|
||||
|
||||
#include "../PhysicsAPI.h"
|
||||
#include "Octree.h"
|
||||
#include <btBulletDynamicsCommon.h>
|
||||
|
||||
namespace Oyster
|
||||
|
@ -65,6 +64,8 @@ namespace Oyster
|
|||
ICustomBody* AddCollisionBox(::Oyster::Math::Float3 halfSize, ::Oyster::Math::Float4 rotation, ::Oyster::Math::Float3 position, float mass, float restitution, float staticFriction, float dynamicFriction);
|
||||
ICustomBody* AddCollisionCylinder(::Oyster::Math::Float3 halfSize, ::Oyster::Math::Float4 rotation, ::Oyster::Math::Float3 position, float mass, float restitution, float staticFriction, float dynamicFriction);
|
||||
|
||||
ICustomBody* AddCharacter(::Oyster::Math::Float height, ::Oyster::Math::Float radius, ::Oyster::Math::Float4 rotation, ::Oyster::Math::Float3 position, float mass, float restitution, float staticFriction, float dynamicFriction);
|
||||
|
||||
void SetTimeStep(float timeStep);
|
||||
|
||||
void UpdateWorld();
|
||||
|
|
|
@ -139,11 +139,59 @@ void SimpleRigidBody::SetRotation(Float3 eulerAngles)
|
|||
this->state.quaternion = Quaternion(Float3(trans.getRotation().x(), trans.getRotation().y(), trans.getRotation().z()), trans.getRotation().w());
|
||||
}
|
||||
|
||||
void SimpleRigidBody::SetRotation(::Oyster::Math::Float4x4 rotation)
|
||||
{
|
||||
btTransform trans;
|
||||
btMatrix3x3 newRotation;
|
||||
btVector3 rightVector(rotation.v[0].x, rotation.v[0].y, rotation.v[0].z);
|
||||
btVector3 upVector(rotation.v[1].x, rotation.v[1].y, rotation.v[1].z);
|
||||
btVector3 forwardVector(rotation.v[2].x, rotation.v[2].y, rotation.v[2].z);
|
||||
|
||||
|
||||
newRotation[0] = rightVector;
|
||||
newRotation[1] = upVector;
|
||||
newRotation[2] = forwardVector;
|
||||
|
||||
trans = this->rigidBody->getWorldTransform();
|
||||
trans.setBasis(newRotation);
|
||||
this->rigidBody->setWorldTransform(trans);
|
||||
|
||||
btQuaternion quaternion;
|
||||
quaternion = trans.getRotation();
|
||||
this->state.quaternion = Quaternion(Float3(quaternion.x(), quaternion.y(), quaternion.z()), quaternion.w());
|
||||
}
|
||||
|
||||
void SimpleRigidBody::SetRotationAsAngularAxis(::Oyster::Math::Float4 angularAxis)
|
||||
{
|
||||
if(angularAxis.xyz.GetMagnitude() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
btTransform trans;
|
||||
btVector3 vector(angularAxis.x, angularAxis.y, angularAxis.z);
|
||||
btQuaternion quaternion(vector, angularAxis.w);
|
||||
|
||||
trans = this->rigidBody->getWorldTransform();
|
||||
trans.setRotation(quaternion);
|
||||
this->rigidBody->setWorldTransform(trans);
|
||||
|
||||
this->state.quaternion = Quaternion(Float3(quaternion.x(), quaternion.y(), quaternion.z()), quaternion.w());
|
||||
}
|
||||
|
||||
void SimpleRigidBody::SetAngularFactor(Float factor)
|
||||
{
|
||||
this->rigidBody->setAngularFactor(factor);
|
||||
}
|
||||
|
||||
void SimpleRigidBody::SetMass(Float mass)
|
||||
{
|
||||
btVector3 fallInertia(0, 0, 0);
|
||||
collisionShape->calculateLocalInertia(mass, fallInertia);
|
||||
this->rigidBody->setMassProps(mass, fallInertia);
|
||||
this->state.mass = mass;
|
||||
}
|
||||
|
||||
void SimpleRigidBody::SetGravity(Float3 gravity)
|
||||
{
|
||||
this->rigidBody->setGravity(btVector3(gravity.x, gravity.y, gravity.z));
|
||||
|
@ -177,7 +225,7 @@ void SimpleRigidBody::SetUpAndForward(::Oyster::Math::Float3 up, ::Oyster::Math:
|
|||
btVector3 forwardVector(forward.x, forward.y, forward.z);
|
||||
rotation[1] = upVector.normalized();
|
||||
rotation[2] = forwardVector.normalized();
|
||||
rotation[0] = forwardVector.cross(upVector).normalized();
|
||||
rotation[0] = upVector.cross(forwardVector).normalized();
|
||||
trans = this->rigidBody->getWorldTransform();
|
||||
trans.setBasis(rotation);
|
||||
this->rigidBody->setWorldTransform(trans);
|
||||
|
@ -187,6 +235,27 @@ void SimpleRigidBody::SetUpAndForward(::Oyster::Math::Float3 up, ::Oyster::Math:
|
|||
this->state.quaternion = Quaternion(Float3(quaternion.x(), quaternion.y(), quaternion.z()), quaternion.w());
|
||||
}
|
||||
|
||||
void SimpleRigidBody::SetUp(::Oyster::Math::Float3 up)
|
||||
{
|
||||
Float3 vector = Float3(0, 1, 0).Cross(up);
|
||||
|
||||
if(vector == Float3::null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Float sine = vector.GetLength();
|
||||
Float cosine = acos(Float3(0, 1, 0).Dot(up));
|
||||
|
||||
btQuaternion quaternion(btVector3(vector.x, vector.y, vector.z),cosine);
|
||||
|
||||
btTransform trans;
|
||||
trans = this->rigidBody->getWorldTransform();
|
||||
trans.setRotation(quaternion);
|
||||
this->rigidBody->setWorldTransform(trans);
|
||||
this->state.quaternion = Quaternion(Float3(quaternion.x(), quaternion.y(), quaternion.z()), quaternion.w());
|
||||
}
|
||||
|
||||
Float4x4 SimpleRigidBody::GetRotation() const
|
||||
{
|
||||
return this->state.GetRotation();
|
||||
|
@ -229,6 +298,16 @@ Float4x4 SimpleRigidBody::GetView( const ::Oyster::Math::Float3 &offset ) const
|
|||
return this->state.GetView(offset);
|
||||
}
|
||||
|
||||
Float3 SimpleRigidBody::GetGravity() const
|
||||
{
|
||||
return this->rigidBody->getGravity();
|
||||
}
|
||||
Float3 SimpleRigidBody::GetLinearVelocity() const
|
||||
{
|
||||
return this->rigidBody->getLinearVelocity();
|
||||
}
|
||||
|
||||
|
||||
void SimpleRigidBody::CallSubscription_AfterCollisionResponse(ICustomBody* bodyA, ICustomBody* bodyB, Oyster::Math::Float kineticEnergyLoss)
|
||||
{
|
||||
if(this->afterCollision)
|
||||
|
@ -265,6 +344,4 @@ void * SimpleRigidBody::GetCustomTag() const
|
|||
void SimpleRigidBody::SetCustomTag( void *ref )
|
||||
{
|
||||
this->customTag = ref;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -19,10 +19,6 @@ namespace Oyster
|
|||
void SetState( const State &state );
|
||||
|
||||
void ApplyImpulse(Math::Float3 impulse);
|
||||
|
||||
void SetCollisionShape(btCollisionShape* shape);
|
||||
void SetMotionState(btDefaultMotionState* motionState);
|
||||
void SetRigidBody(btRigidBody* rigidBody);
|
||||
|
||||
void SetSubscription(EventAction_AfterCollisionResponse function);
|
||||
void SetSubscription(EventAction_Move function);
|
||||
|
@ -32,18 +28,25 @@ namespace Oyster
|
|||
void SetRotation(Math::Float4 quaternion);
|
||||
void SetRotation(Math::Quaternion quaternion);
|
||||
void SetRotation(Math::Float3 eulerAngles);
|
||||
void SetRotation(::Oyster::Math::Float4x4 rotation);
|
||||
void SetRotationAsAngularAxis(Math::Float4 angularAxis);
|
||||
void SetAngularFactor(Math::Float factor);
|
||||
void SetMass(Math::Float mass);
|
||||
|
||||
void SetGravity(Math::Float3 gravity);
|
||||
|
||||
void SetUpAndRight(::Oyster::Math::Float3 up, ::Oyster::Math::Float3 right);
|
||||
void SetUpAndForward(::Oyster::Math::Float3 up, ::Oyster::Math::Float3 forward);
|
||||
void SetUpAndRight(Math::Float3 up, Math::Float3 right);
|
||||
void SetUpAndForward(Math::Float3 up, Math::Float3 forward);
|
||||
void SetUp(Math::Float3 up);
|
||||
|
||||
Math::Float4x4 GetRotation() const;
|
||||
Math::Float4 GetRotationAsAngularAxis();
|
||||
Math::Float4x4 GetOrientation() const;
|
||||
Math::Float4x4 GetView() const;
|
||||
Math::Float4x4 GetView( const ::Oyster::Math::Float3 &offset ) const;
|
||||
Math::Float4x4 GetView( const Math::Float3 &offset ) const;
|
||||
|
||||
Math::Float3 GetGravity() const;
|
||||
::Oyster::Math::Float3 GetLinearVelocity() const;
|
||||
|
||||
void CallSubscription_AfterCollisionResponse(ICustomBody* bodyA, ICustomBody* bodyB, Math::Float kineticEnergyLoss);
|
||||
void CallSubscription_Move();
|
||||
|
@ -55,6 +58,11 @@ namespace Oyster
|
|||
void SetCustomTag( void *ref );
|
||||
void* GetCustomTag() const;
|
||||
|
||||
// Class specific
|
||||
void SetCollisionShape(btCollisionShape* shape);
|
||||
void SetMotionState(btDefaultMotionState* motionState);
|
||||
void SetRigidBody(btRigidBody* rigidBody);
|
||||
|
||||
private:
|
||||
|
||||
btCollisionShape* collisionShape;
|
||||
|
|
|
@ -87,6 +87,8 @@ namespace Oyster
|
|||
virtual ICustomBody* AddCollisionBox(::Oyster::Math::Float3 halfSize, ::Oyster::Math::Float4 rotation, ::Oyster::Math::Float3 position, float mass, float restitution, float staticFriction, float dynamicFriction) = 0;
|
||||
virtual ICustomBody* AddCollisionCylinder(::Oyster::Math::Float3 halfSize, ::Oyster::Math::Float4 rotation, ::Oyster::Math::Float3 position, float mass, float restitution, float staticFriction, float dynamicFriction) = 0;
|
||||
|
||||
virtual ICustomBody* AddCharacter(::Oyster::Math::Float height, ::Oyster::Math::Float radius, ::Oyster::Math::Float4 rotation, ::Oyster::Math::Float3 position, float mass, float restitution, float staticFriction, float dynamicFriction) = 0;
|
||||
|
||||
virtual void SetTimeStep(float timeStep) = 0;
|
||||
|
||||
virtual void UpdateWorld() = 0;
|
||||
|
@ -142,12 +144,16 @@ namespace Oyster
|
|||
virtual void SetRotation(::Oyster::Math::Float4 quaternion) = 0;
|
||||
virtual void SetRotation(::Oyster::Math::Quaternion quaternion) = 0;
|
||||
virtual void SetRotation(::Oyster::Math::Float3 eulerAngles) = 0;
|
||||
virtual void SetRotation(::Oyster::Math::Float4x4 rotation) = 0;
|
||||
virtual void SetRotationAsAngularAxis(::Oyster::Math::Float4 angularAxis) = 0;
|
||||
virtual void SetAngularFactor(::Oyster::Math::Float factor) = 0;
|
||||
virtual void SetMass(::Oyster::Math::Float mass) = 0;
|
||||
|
||||
virtual void SetGravity(::Oyster::Math::Float3 gravity) = 0;
|
||||
|
||||
virtual void SetUpAndRight(::Oyster::Math::Float3 up, ::Oyster::Math::Float3 right) = 0;
|
||||
virtual void SetUpAndForward(::Oyster::Math::Float3 up, ::Oyster::Math::Float3 forward) = 0;
|
||||
virtual void SetUp(::Oyster::Math::Float3 up) = 0;
|
||||
|
||||
virtual ::Oyster::Math::Float4x4 GetRotation() const = 0;
|
||||
virtual ::Oyster::Math::Float4 GetRotationAsAngularAxis() = 0;
|
||||
|
@ -155,6 +161,12 @@ namespace Oyster
|
|||
virtual ::Oyster::Math::Float4x4 GetView() const = 0;
|
||||
virtual ::Oyster::Math::Float4x4 GetView(const ::Oyster::Math::Float3 &offset) const = 0;
|
||||
|
||||
virtual ::Oyster::Math::Float3 GetGravity() const = 0;
|
||||
virtual ::Oyster::Math::Float3 GetLinearVelocity() const = 0;
|
||||
|
||||
virtual void CallSubscription_AfterCollisionResponse(ICustomBody* bodyA, ICustomBody* bodyB, Math::Float kineticEnergyLoss) = 0;
|
||||
virtual void CallSubscription_Move() = 0;
|
||||
|
||||
/********************************************************
|
||||
* @return the void pointer set by SetCustomTag.
|
||||
* nullptr if none is set.
|
||||
|
@ -172,6 +184,5 @@ namespace Oyster
|
|||
}
|
||||
|
||||
#include "PhysicsStructs.h"
|
||||
#include "PhysicsFormula.h"
|
||||
|
||||
#endif
|
|
@ -1,82 +0,0 @@
|
|||
#ifndef PHYSICS_FORMULA_IMPL_H
|
||||
#define PHYSICS_FORMULA_IMPL_H
|
||||
|
||||
#include "PhysicsFormula.h"
|
||||
#include "OysterPhysics3D.h"
|
||||
|
||||
namespace Oyster { namespace Physics { namespace Formula
|
||||
{
|
||||
namespace MomentOfInertia
|
||||
{
|
||||
inline ::Oyster::Math::Float4x4 CreateSphereMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float radius )
|
||||
{
|
||||
return ::Oyster::Physics3D::Formula::MomentOfInertia::Sphere(mass, radius);
|
||||
}
|
||||
|
||||
inline ::Oyster::Math::Float4x4 CreateHollowSphereMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float radius )
|
||||
{
|
||||
return ::Oyster::Physics3D::Formula::MomentOfInertia::HollowSphere(mass, radius);
|
||||
}
|
||||
|
||||
inline ::Oyster::Math::Float4x4 CreateCuboidMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float height, const ::Oyster::Math::Float width, const ::Oyster::Math::Float depth )
|
||||
{
|
||||
return ::Oyster::Physics3D::Formula::MomentOfInertia::Cuboid(mass, height, width, depth);
|
||||
}
|
||||
|
||||
inline ::Oyster::Math::Float4x4 CreateCylinderMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float height, const ::Oyster::Math::Float radius )
|
||||
{
|
||||
return ::Oyster::Physics3D::Formula::MomentOfInertia::Cylinder(mass, height, radius);
|
||||
}
|
||||
|
||||
inline ::Oyster::Math::Float4x4 CreateRodMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float length )
|
||||
{
|
||||
return ::Oyster::Physics3D::Formula::MomentOfInertia::RodCenter(mass, length);
|
||||
}
|
||||
}
|
||||
|
||||
namespace CollisionResponse
|
||||
{
|
||||
inline ::Oyster::Math::Float Bounce( ::Oyster::Math::Float e, ::Oyster::Math::Float mA, ::Oyster::Math::Float gA, ::Oyster::Math::Float mB, ::Oyster::Math::Float gB )
|
||||
{
|
||||
//return (e + 1) * (mB*gA - mA*gB) / (mA + mB);
|
||||
return (e + 1) * (mA*gB - mB*gA) / (mA + mB);
|
||||
}
|
||||
|
||||
inline ::Oyster::Math::Float4 Friction( ::Oyster::Math::Float i, ::Oyster::Math::Float4 iN, ::Oyster::Math::Float4 momA, ::Oyster::Math::Float sFA, ::Oyster::Math::Float dFA, ::Oyster::Math::Float mA, ::Oyster::Math::Float4 momB, ::Oyster::Math::Float sFB, ::Oyster::Math::Float dFB, ::Oyster::Math::Float mB )
|
||||
{
|
||||
// FRICTION
|
||||
// Relative momentum after normal impulse
|
||||
::Oyster::Math::Float4 relativeMomentum = momB - momA;
|
||||
|
||||
::Oyster::Math::Float4 tanFriction = relativeMomentum - relativeMomentum.Dot( iN ) * iN;
|
||||
|
||||
if( tanFriction.Dot(tanFriction) > 0.0f )
|
||||
{ // no friction if moving directly into surface, or not at all.
|
||||
tanFriction.Normalize();
|
||||
|
||||
::Oyster::Math::Float magnitudeFriction = -relativeMomentum.Dot( tanFriction );
|
||||
magnitudeFriction = magnitudeFriction * mA * mB / ( mA + mB );
|
||||
|
||||
::Oyster::Math::Float mu = 0.5f * ( sFA + sFB );
|
||||
|
||||
::Oyster::Math::Float4 frictionImpulse;
|
||||
if( abs(magnitudeFriction) < i * mu )
|
||||
{
|
||||
frictionImpulse = magnitudeFriction * tanFriction;
|
||||
}
|
||||
else
|
||||
{
|
||||
::Oyster::Math::Float dynamicFriction = 0.5f * ( dFA + dFB );
|
||||
frictionImpulse = ( -i * dynamicFriction ) * tanFriction;
|
||||
}
|
||||
|
||||
return ( 1 / mA ) * frictionImpulse;
|
||||
}
|
||||
else
|
||||
return ::Oyster::Math::Float4::null;
|
||||
}
|
||||
}
|
||||
|
||||
} } }
|
||||
|
||||
#endif
|
|
@ -1,35 +0,0 @@
|
|||
#ifndef PHYSICS_FORMULA_H
|
||||
#define PHYSICS_FORMULA_H
|
||||
|
||||
#include "OysterMath.h"
|
||||
#include "OysterPhysics3D.h"
|
||||
|
||||
namespace Oyster { namespace Physics { namespace Formula
|
||||
{
|
||||
namespace MomentOfInertia
|
||||
{
|
||||
::Oyster::Math::Float4x4 CreateSphereMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float radius );
|
||||
::Oyster::Math::Float4x4 CreateHollowSphereMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float radius );
|
||||
::Oyster::Math::Float4x4 CreateCuboidMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float height, const ::Oyster::Math::Float width, const ::Oyster::Math::Float depth );
|
||||
::Oyster::Math::Float4x4 CreateCylinderMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float height, const ::Oyster::Math::Float radius );
|
||||
::Oyster::Math::Float4x4 CreateRodMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float length );
|
||||
}
|
||||
|
||||
namespace CollisionResponse
|
||||
{
|
||||
::Oyster::Math::Float Bounce( ::Oyster::Math::Float coeffOfRestitution,
|
||||
::Oyster::Math::Float massA, ::Oyster::Math::Float momentumA,
|
||||
::Oyster::Math::Float massB, ::Oyster::Math::Float momentumB );
|
||||
|
||||
::Oyster::Math::Float4 Friction( ::Oyster::Math::Float impulse, ::Oyster::Math::Float4 impulseNormal,
|
||||
::Oyster::Math::Float4 momentumA, ::Oyster::Math::Float staticFrictionA,
|
||||
::Oyster::Math::Float dynamicFrictionA, ::Oyster::Math::Float massA,
|
||||
::Oyster::Math::Float4 momentumB, ::Oyster::Math::Float staticFrictionB,
|
||||
::Oyster::Math::Float dynamicFrictionB, ::Oyster::Math::Float massB );
|
||||
|
||||
}
|
||||
} } }
|
||||
|
||||
#include "PhysicsFormula-Impl.h"
|
||||
|
||||
#endif
|
|
@ -73,6 +73,15 @@ namespace Oyster
|
|||
int offset;
|
||||
float coff;
|
||||
};
|
||||
|
||||
struct BlurrData
|
||||
{
|
||||
unsigned int StartX;
|
||||
unsigned int StartY;
|
||||
unsigned int StopX;
|
||||
unsigned int StopY;
|
||||
Math::Float4 BlurMask;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -87,6 +87,7 @@ namespace Oyster
|
|||
m->WorldMatrix = Oyster::Math::Float4x4::identity;
|
||||
m->Visible = true;
|
||||
m->Animation.AnimationPlaying = NULL;
|
||||
m->Tint = Math::Float3(1);
|
||||
m->info = (Model::ModelInfo*)Core::loader.LoadResource((Core::modelPath + filename).c_str(),Oyster::Graphics::Loading::LoadDAN, Oyster::Graphics::Loading::UnloadDAN);
|
||||
|
||||
Model::ModelInfo* mi = (Model::ModelInfo*)m->info;
|
||||
|
@ -158,7 +159,7 @@ namespace Oyster
|
|||
Render::Gui::Begin2DRender();
|
||||
}
|
||||
|
||||
void API::RenderGuiElement(API::Texture tex, Math::Float2 pos, Math::Float2 size, Math::Float3 color)
|
||||
void API::RenderGuiElement(API::Texture tex, Math::Float3 pos, Math::Float2 size, Math::Float3 color)
|
||||
{
|
||||
Render::Gui::Render((ID3D11ShaderResourceView*)tex,pos,size,color);
|
||||
}
|
||||
|
@ -191,9 +192,9 @@ namespace Oyster
|
|||
Render::Gui::Begin2DTextRender();
|
||||
}
|
||||
|
||||
void API::RenderText(std::wstring text, Math::Float2 Pos, Math::Float2 Size, Math::Float3 color)
|
||||
void API::RenderText(std::wstring text, Math::Float3 Pos, Math::Float2 Size, float FontSize, Math::Float3 color)
|
||||
{
|
||||
Render::Gui::RenderText(text,Pos,Size,color);
|
||||
Render::Gui::RenderText(text, Pos, Size, FontSize, color);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -57,13 +57,13 @@ namespace Oyster
|
|||
static void StartGuiRender();
|
||||
|
||||
//! @brief Renders a single GUI element using the texture provided and the Pos in the center, %based system
|
||||
static void RenderGuiElement(Texture, Math::Float2 Pos, Math::Float2 Size, Math::Float3 Color = Math::Float3(1,1,1));
|
||||
static void RenderGuiElement(Texture, Math::Float3 Pos, Math::Float2 Size, Math::Float3 Color = Math::Float3(1,1,1));
|
||||
|
||||
//! @brief Configures Renderer to process 2D Text, data will be passed in to EndFrame()
|
||||
static void StartTextRender();
|
||||
|
||||
//! @brief Renders a single GUI string using the texture provided and the Pos in the center, %based system
|
||||
static void RenderText(std::wstring, Math::Float2 Pos, Math::Float2 Size, Math::Float3 Color = Math::Float3(1,1,1));
|
||||
static void RenderText(std::wstring, Math::Float3 Pos, Math::Float2 Size, float FontSize, Math::Float3 Color = Math::Float3(1,1,1));
|
||||
|
||||
//! @brief Performs light calculations, post effects and presents the scene
|
||||
static void EndFrame();
|
||||
|
|
|
@ -23,6 +23,7 @@ namespace Oyster
|
|||
{
|
||||
ModelInfo* info;
|
||||
Oyster::Math::Float4x4 WorldMatrix;
|
||||
Oyster::Math::Float3 Tint;
|
||||
bool Visible;
|
||||
AnimationData Animation;
|
||||
};
|
||||
|
|
|
@ -138,6 +138,10 @@ namespace Oyster
|
|||
memcpy(data,&(pm),sizeof(pm));
|
||||
Resources::Gather::ModelData.Unmap();
|
||||
|
||||
data = Render::Resources::Color.Map();
|
||||
memcpy(data,&models[i].Tint,sizeof(Math::Float3));
|
||||
Render::Resources::Color.Unmap();
|
||||
|
||||
if(info->Material.size())
|
||||
{
|
||||
Core::deviceContext->PSSetShaderResources(0,(UINT)info->Material.size(),&(info->Material[0]));
|
||||
|
@ -158,6 +162,46 @@ namespace Oyster
|
|||
}
|
||||
}
|
||||
|
||||
void BlurGlow()
|
||||
{
|
||||
Definitions::BlurrData bd;
|
||||
bd.BlurMask = Math::Float4(1,1,1,1);
|
||||
bd.StopX = Core::resolution.x/2;
|
||||
bd.StopY = Core::resolution.y;
|
||||
bd.StartX = 0;
|
||||
bd.StartY = Core::resolution.y/2;
|
||||
|
||||
void* data = Resources::Blur::Data.Map();
|
||||
memcpy(data,&bd,sizeof(Definitions::BlurrData));
|
||||
Resources::Blur::Data.Unmap();
|
||||
|
||||
Core::PipelineManager::SetRenderPass(Resources::Blur::HorPass);
|
||||
Core::deviceContext->Dispatch((UINT)((Core::resolution.x/2 + 127U) / 128U), (UINT)(Core::resolution.y/2), 1);
|
||||
|
||||
Core::PipelineManager::SetRenderPass(Resources::Blur::VertPass);
|
||||
Core::deviceContext->Dispatch((UINT)(Core::resolution.x/2), (UINT)((Core::resolution.y/2 + 127U) / 128U), 1);
|
||||
}
|
||||
|
||||
void BlurSSAO()
|
||||
{
|
||||
Definitions::BlurrData bd;
|
||||
bd.BlurMask = Math::Float4(0,0,0,1);
|
||||
bd.StopX = Core::resolution.x/2;
|
||||
bd.StopY = Core::resolution.y/2;
|
||||
bd.StartX = 0;
|
||||
bd.StartY = 0;
|
||||
|
||||
void* data = Resources::Blur::Data.Map();
|
||||
memcpy(data,&bd,sizeof(Definitions::BlurrData));
|
||||
Resources::Blur::Data.Unmap();
|
||||
|
||||
Core::PipelineManager::SetRenderPass(Resources::Blur::HorPass);
|
||||
Core::deviceContext->Dispatch((UINT)((Core::resolution.x/2 + 127U) / 128U), (UINT)(Core::resolution.y/2), 1);
|
||||
|
||||
Core::PipelineManager::SetRenderPass(Resources::Blur::VertPass);
|
||||
Core::deviceContext->Dispatch((UINT)(Core::resolution.x/2), (UINT)((Core::resolution.y/2 + 127U) / 128U), 1);
|
||||
}
|
||||
|
||||
|
||||
void DefaultRenderer::EndFrame()
|
||||
{
|
||||
|
@ -165,11 +209,9 @@ namespace Oyster
|
|||
|
||||
Core::deviceContext->Dispatch((UINT)((Core::resolution.x + 15U) / 16U), (UINT)((Core::resolution.y + 15U) / 16U), 1);
|
||||
|
||||
//Core::PipelineManager::SetRenderPass(Resources::Blur::HorPass);
|
||||
//Core::deviceContext->Dispatch((UINT)((Core::resolution.x + 15U) / 16U), (UINT)((Core::resolution.y + 15U) / 16U), 1);
|
||||
BlurGlow();
|
||||
|
||||
//Core::PipelineManager::SetRenderPass(Resources::Blur::VertPass);
|
||||
//Core::deviceContext->Dispatch((UINT)((Core::resolution.x + 15U) / 16U), (UINT)((Core::resolution.y + 15U) / 16U), 1);
|
||||
BlurSSAO();
|
||||
|
||||
Core::PipelineManager::SetRenderPass(Resources::Post::Pass);
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Oyster
|
|||
Core::PipelineManager::SetRenderPass(Render::Resources::Gui::Pass);
|
||||
}
|
||||
|
||||
void Gui::Render(ID3D11ShaderResourceView* tex,Math::Float2 pos, Math::Float2 size, Math::Float3 color)
|
||||
void Gui::Render(ID3D11ShaderResourceView* tex,Math::Float3 pos, Math::Float2 size, Math::Float3 color)
|
||||
{
|
||||
Core::deviceContext->PSSetShaderResources(0,1,&tex);
|
||||
|
||||
|
@ -28,6 +28,7 @@ namespace Oyster
|
|||
gd.Translation = Math::Matrix::identity;
|
||||
gd.Translation.m41 = pos.x;
|
||||
gd.Translation.m42 = pos.y;
|
||||
gd.Translation.m43 = pos.z;
|
||||
gd.Translation.m11 = size.x;
|
||||
gd.Translation.m22 = size.y;
|
||||
|
||||
|
@ -35,9 +36,9 @@ namespace Oyster
|
|||
memcpy(data,&gd,sizeof(Definitions::GuiData));
|
||||
Render::Resources::Gui::Data.Unmap();
|
||||
|
||||
data = Render::Resources::Gui::Color.Map();
|
||||
data = Render::Resources::Color.Map();
|
||||
memcpy(data,&color,sizeof(Math::Float3));
|
||||
Render::Resources::Gui::Color.Unmap();
|
||||
Render::Resources::Color.Unmap();
|
||||
|
||||
|
||||
Core::deviceContext->Draw(1,0);
|
||||
|
@ -49,10 +50,10 @@ namespace Oyster
|
|||
Core::PipelineManager::SetRenderPass(Resources::Gui::Text::Pass);
|
||||
}
|
||||
|
||||
void Gui::RenderText(std::wstring text, Math::Float2 pos, Math::Float2 size, Math::Float3 color)
|
||||
void Gui::RenderText(std::wstring text, Math::Float3 pos, Math::Float2 size, float FontSize, Math::Float3 color)
|
||||
{
|
||||
|
||||
size.x = size.x / (text.length() * TEXT_SPACING /2);
|
||||
//size.x = size.x / (text.length() * TEXT_SPACING /2);
|
||||
|
||||
|
||||
pos *= 2;
|
||||
|
@ -60,15 +61,18 @@ namespace Oyster
|
|||
pos.y *= -1;
|
||||
|
||||
|
||||
pos.x = pos.x - (size.x * (text.length()-1) * TEXT_SPACING /2);
|
||||
//pos.x = pos.x - (size.x * (text.length()-1) * TEXT_SPACING /2);
|
||||
pos.x = pos.x + size.x/ (text.length() * TEXT_SPACING/2);
|
||||
pos.y = pos.y - size.y/2;
|
||||
|
||||
Definitions::GuiData gd;
|
||||
|
||||
gd.Translation = Math::Matrix::identity;
|
||||
gd.Translation.m41 = pos.x;
|
||||
gd.Translation.m42 = pos.y;
|
||||
gd.Translation.m11 = size.x;
|
||||
gd.Translation.m22 = size.y;
|
||||
gd.Translation.m43 = pos.z;
|
||||
gd.Translation.m11 = FontSize * 0.8f;
|
||||
gd.Translation.m22 = FontSize;
|
||||
|
||||
|
||||
void* data = Render::Resources::Gui::Data.Map();
|
||||
|
@ -76,25 +80,26 @@ namespace Oyster
|
|||
Render::Resources::Gui::Data.Unmap();
|
||||
Definitions::Text2D tmpInst;
|
||||
|
||||
data = Render::Resources::Gui::Color.Map();
|
||||
data = Render::Resources::Color.Map();
|
||||
memcpy(data,&color,sizeof(Math::Float3));
|
||||
Render::Resources::Gui::Color.Unmap();
|
||||
Render::Resources::Color.Unmap();
|
||||
|
||||
void* dest = Resources::Gui::Text::Vertex.Map();
|
||||
Definitions::Text2D* dataView = reinterpret_cast<Definitions::Text2D*>(dest);
|
||||
//tmpInst.charOffset=_pos;
|
||||
|
||||
for (unsigned int i=0; i<text.length(); i++)
|
||||
{
|
||||
tmpInst.coff=(1.0f/TEXT_NR_LETTERS);
|
||||
tmpInst.offset=text[i]-32;
|
||||
tmpInst.pos=i*(size.x * TEXT_SPACING);
|
||||
//float tst=getCharID(_str[i]);
|
||||
//tmpInst.offset=tst;
|
||||
//tmpInst.charOffset.x=_pos.x-i*TEXT_SIZE;
|
||||
//tmpInst.data=tst;
|
||||
tmpInst.pos=i*(FontSize * 0.8f * TEXT_SPACING);
|
||||
if(tmpInst.pos > size.x)
|
||||
{
|
||||
text = text.substr(0,i-1);
|
||||
break;
|
||||
}
|
||||
dataView[i]=tmpInst;
|
||||
}
|
||||
//TextInstances[_id].NumLetters=instances;
|
||||
|
||||
Resources::Gui::Text::Vertex.Unmap();
|
||||
|
||||
|
||||
|
|
|
@ -12,9 +12,9 @@ namespace Oyster
|
|||
{
|
||||
public:
|
||||
static void Begin2DRender();
|
||||
static void Render(ID3D11ShaderResourceView* tex, Math::Float2 pos, Math::Float2 size, Math::Float3 tint = Math::Float3(1,1,1));
|
||||
static void Render(ID3D11ShaderResourceView* tex, Math::Float3 pos, Math::Float2 size, Math::Float3 tint = Math::Float3(1,1,1));
|
||||
static void Begin2DTextRender();
|
||||
static void RenderText(std::wstring text, Math::Float2 pos, Math::Float2 size, Math::Float3 tint = Math::Float3(1,1,1));
|
||||
static void RenderText(std::wstring text, Math::Float3 pos, Math::Float2 size, float FontSize, Math::Float3 tint = Math::Float3(1,1,1));
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,8 +23,8 @@ namespace Oyster
|
|||
{
|
||||
namespace Render
|
||||
{
|
||||
|
||||
ID3D11RenderTargetView* Resources::GBufferRTV[Resources::GBufferSize] = {0};
|
||||
#pragma region Declare Static
|
||||
ID3D11RenderTargetView* Resources::GBufferRTV[Resources::GBufferSize] = {0};
|
||||
ID3D11ShaderResourceView* Resources::GBufferSRV[Resources::GBufferSize] = {0};
|
||||
|
||||
ID3D11UnorderedAccessView* Resources::LBufferUAV[Resources::LBufferSize] = {0};
|
||||
|
@ -45,9 +45,10 @@ namespace Oyster
|
|||
Buffer Resources::Gather::AnimationData = Buffer();
|
||||
Buffer Resources::Light::LightConstantsData = Buffer();
|
||||
Buffer Resources::Gui::Data = Buffer();
|
||||
Buffer Resources::Gui::Color = Buffer();
|
||||
Buffer Resources::Color = Buffer();
|
||||
Buffer Resources::Gui::Text::Vertex = Buffer();
|
||||
Buffer Resources::Post::Data = Buffer();
|
||||
Buffer Resources::Blur::Data = Buffer();
|
||||
|
||||
Buffer Resources::Light::PointLightsData = Buffer();
|
||||
ID3D11ShaderResourceView* Resources::Light::PointLightView = NULL;
|
||||
|
@ -61,6 +62,7 @@ namespace Oyster
|
|||
ID3D11BlendState* Resources::RenderStates::bs = NULL;
|
||||
|
||||
ID3D11ShaderResourceView* Resources::Gui::Text::Font = NULL;
|
||||
#pragma endregion
|
||||
|
||||
|
||||
Core::Init::State Resources::InitShaders()
|
||||
|
@ -121,7 +123,7 @@ namespace Oyster
|
|||
|
||||
desc.Type = Buffer::BUFFER_TYPE::CONSTANT_BUFFER_PS;
|
||||
desc.ElementSize = sizeof(Math::Float3);
|
||||
Gui::Color.Init(desc);
|
||||
Color.Init(desc);
|
||||
|
||||
desc.Type = Buffer::BUFFER_TYPE::CONSTANT_BUFFER_GS;
|
||||
desc.NumElements = 1;
|
||||
|
@ -135,6 +137,9 @@ namespace Oyster
|
|||
desc.ElementSize = sizeof(Definitions::LightConstants);
|
||||
Light::LightConstantsData.Init(desc);
|
||||
|
||||
desc.ElementSize = sizeof(Definitions::BlurrData);
|
||||
Blur::Data.Init(desc);
|
||||
|
||||
desc.ElementSize = sizeof(Definitions::Pointlight);
|
||||
desc.NumElements = MaxLightSize;
|
||||
desc.Type = Buffer::STRUCTURED_BUFFER;
|
||||
|
@ -235,6 +240,9 @@ namespace Oyster
|
|||
Core::Init::CreateLinkedShaderResourceFromTexture(NULL,&LBufferSRV[i],&LBufferUAV[i]);
|
||||
}
|
||||
|
||||
//Blur
|
||||
Core::Init::CreateLinkedShaderResourceFromTexture(NULL,&Blur::BufferSRV,&Blur::BufferUAV);
|
||||
|
||||
Buffer* b = &Light::PointLightsData;
|
||||
|
||||
Core::Init::CreateLinkedShaderResourceFromStructuredBuffer(&b,&Light::PointLightView,NULL);
|
||||
|
@ -342,6 +350,7 @@ namespace Oyster
|
|||
Gather::Pass.IAStage.Topology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
|
||||
Gather::Pass.CBuffers.Vertex.push_back(Gather::AnimationData);
|
||||
Gather::Pass.CBuffers.Vertex.push_back(Gather::ModelData);
|
||||
Gather::Pass.CBuffers.Pixel.push_back(Color);
|
||||
Gather::Pass.RenderStates.Rasterizer = RenderStates::rs;
|
||||
Gather::Pass.RenderStates.SampleCount = 1;
|
||||
Gather::Pass.RenderStates.SampleState = RenderStates::ss;
|
||||
|
@ -376,6 +385,8 @@ namespace Oyster
|
|||
}
|
||||
Post::Pass.UAV.Compute.push_back(Core::backBufferUAV);
|
||||
Post::Pass.CBuffers.Compute.push_back(Post::Data);
|
||||
Post::Pass.RenderStates.SampleCount = 1;
|
||||
Post::Pass.RenderStates.SampleState = RenderStates::ss;
|
||||
|
||||
////---------------- GUI Pass Setup ----------------------------
|
||||
Gui::Pass.Shaders.Vertex = GetShader::Vertex(L"2D");
|
||||
|
@ -383,7 +394,7 @@ namespace Oyster
|
|||
Gui::Pass.Shaders.Geometry = GetShader::Geometry(L"2D");
|
||||
Gui::Pass.RTV.push_back(GBufferRTV[2]);
|
||||
Gui::Pass.CBuffers.Geometry.push_back(Gui::Data);
|
||||
Gui::Pass.CBuffers.Pixel.push_back(Gui::Color);
|
||||
Gui::Pass.CBuffers.Pixel.push_back(Color);
|
||||
|
||||
D3D11_INPUT_ELEMENT_DESC indesc2D[] =
|
||||
{
|
||||
|
@ -411,6 +422,9 @@ namespace Oyster
|
|||
//And the Ambient UAV is now the output texture
|
||||
Blur::VertPass.UAV.Compute.push_back(LBufferUAV[2]);
|
||||
|
||||
Blur::HorPass.CBuffers.Compute.push_back(Blur::Data);
|
||||
Blur::VertPass.CBuffers.Compute.push_back(Blur::Data);
|
||||
|
||||
////---------------- 2DText Pass Setup ----------------------------
|
||||
Gui::Text::Pass.Shaders.Vertex = GetShader::Vertex(L"2DText");
|
||||
Gui::Text::Pass.Shaders.Geometry = GetShader::Geometry(L"2DText");
|
||||
|
@ -427,7 +441,7 @@ namespace Oyster
|
|||
|
||||
Shader::CreateInputLayout(Text2Ddesc,3, GetShader::Vertex(L"2DText") ,Gui::Text::Pass.IAStage.Layout);
|
||||
Gui::Text::Pass.CBuffers.Geometry.push_back(Gui::Data);
|
||||
Gui::Text::Pass.CBuffers.Pixel.push_back(Gui::Color);
|
||||
Gui::Text::Pass.CBuffers.Pixel.push_back(Color);
|
||||
Gui::Text::Pass.SRV.Pixel.push_back(Gui::Text::Font);
|
||||
Gui::Text::Pass.RTV.push_back(GBufferRTV[2]);
|
||||
Gui::Text::Pass.RenderStates.SampleCount = 1;
|
||||
|
@ -455,9 +469,10 @@ namespace Oyster
|
|||
Light::LightConstantsData.~Buffer();
|
||||
Light::PointLightsData.~Buffer();
|
||||
Gui::Data.~Buffer();
|
||||
Gui::Color.~Buffer();
|
||||
Color.~Buffer();
|
||||
Gui::Text::Vertex.~Buffer();
|
||||
Post::Data.~Buffer();
|
||||
Blur::Data.~Buffer();
|
||||
SAFE_RELEASE(Light::PointLightView);
|
||||
SAFE_RELEASE(Light::SSAOKernel);
|
||||
SAFE_RELEASE(Light::SSAORandom);
|
||||
|
|
|
@ -30,6 +30,9 @@ namespace Oyster
|
|||
static ID3D11UnorderedAccessView* LBufferUAV[LBufferSize];
|
||||
static ID3D11ShaderResourceView* LBufferSRV[LBufferSize];
|
||||
|
||||
|
||||
static Core::Buffer Color;
|
||||
|
||||
|
||||
struct RenderStates
|
||||
{
|
||||
|
@ -61,7 +64,6 @@ namespace Oyster
|
|||
{
|
||||
static Core::PipelineManager::RenderPass Pass;
|
||||
static Core::Buffer Data;
|
||||
static Core::Buffer Color;
|
||||
struct Text
|
||||
{
|
||||
static Core::PipelineManager::RenderPass Pass;
|
||||
|
@ -79,6 +81,8 @@ namespace Oyster
|
|||
//Blur UAV and SRV
|
||||
static ID3D11UnorderedAccessView* BufferUAV;
|
||||
static ID3D11ShaderResourceView* BufferSRV;
|
||||
|
||||
static Core::Buffer Data;
|
||||
};
|
||||
|
||||
struct Post
|
||||
|
|
|
@ -7,14 +7,14 @@ void main(int3 ThreadID : SV_DispatchThreadID, int3 gThreadID : SV_GroupThreadID
|
|||
if(gThreadID.x < blurRadius)
|
||||
{
|
||||
int x = max(ThreadID.x-blurRadius,0);
|
||||
gCache[gThreadID.x] = inTex[int2(x,ThreadID.y)];
|
||||
gCache[gThreadID.x] = inTex[min(int2(x,ThreadID.y) + Start, Stop-1)];
|
||||
}
|
||||
if(gThreadID.x >= N-blurRadius)
|
||||
{
|
||||
int x = min(ThreadID.x+blurRadius,inTex.Length.x-1);
|
||||
gCache[gThreadID.x+2*blurRadius] = inTex[int2(x,ThreadID.y)];
|
||||
int x = min(ThreadID.x+blurRadius,Stop.x-1);
|
||||
gCache[gThreadID.x+2*blurRadius] = inTex[int2(x,ThreadID.y) + Start];
|
||||
}
|
||||
gCache[gThreadID.x+blurRadius] = inTex[min(ThreadID.xy,inTex.Length.xy-1)];
|
||||
gCache[gThreadID.x+blurRadius] = inTex[min(ThreadID.xy + Start, Stop-1)];
|
||||
|
||||
GroupMemoryBarrierWithGroupSync();
|
||||
|
||||
|
@ -27,7 +27,6 @@ void main(int3 ThreadID : SV_DispatchThreadID, int3 gThreadID : SV_GroupThreadID
|
|||
blurCol +=Weights[i + blurRadius] * gCache[k];
|
||||
}
|
||||
|
||||
outTex[ThreadID.xy] = blurCol;
|
||||
//Output[ThreadID.xy] = Diffuse[((ThreadID.xy))];
|
||||
outTex[ThreadID.xy + Start] = blurCol * BlurMask + inTex[ThreadID.xy + Start] * ( float4(1,1,1,1) - BlurMask);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,12 +3,26 @@
|
|||
|
||||
|
||||
|
||||
static const float Weights[9] =
|
||||
cbuffer BlurrData : register(b1)
|
||||
{
|
||||
0.05f, 0.05f, 0.1f, 0.15f, 0.3f, 0.15f, 0.1f, 0.05f, 0.05f
|
||||
//static const int blurRadius = 0;
|
||||
//static const float Weights[1] =
|
||||
//{
|
||||
// 1.0f
|
||||
//};
|
||||
/*static const int blurRadius = 4;
|
||||
static const float Weights[9] =
|
||||
{
|
||||
0.05f, 0.05f, 0.1f, 0.15f, 0.3f, 0.15f, 0.1f, 0.05f, 0.05f
|
||||
};*/
|
||||
static const int blurRadius = 5;
|
||||
static const float Weights[11] =
|
||||
{
|
||||
0.05f,0.05f,0.1f,0.1f,0.1f,0.2f,0.1f,0.1f,0.1f,0.05f,0.05f
|
||||
};
|
||||
};
|
||||
|
||||
static const int blurRadius = 4;
|
||||
|
||||
|
||||
#define N 128
|
||||
#define gSize (N+2*blurRadius)
|
||||
|
@ -17,14 +31,13 @@ groupshared float4 gCache[gSize];
|
|||
Texture2D inTex : register(t0);
|
||||
RWTexture2D<float4> outTex : register(u0);
|
||||
|
||||
//cbuffer BlurrData : register(c0)
|
||||
//{
|
||||
// static const int blurRadius = 5;
|
||||
// static const float Weights[11] =
|
||||
// {
|
||||
// 0.05f,0.05f,0.1f,0.1f,0.1f,0.2f,0.1f,0.1f,0.1f,0.05f,0.05f
|
||||
// };
|
||||
//};
|
||||
cbuffer BlurrData : register(b0)
|
||||
{
|
||||
uint2 Start;
|
||||
uint2 Stop;
|
||||
float4 BlurMask;
|
||||
};
|
||||
|
||||
|
||||
//[numthreads(16,16,1)]
|
||||
//void TryCompute(uint3 ThreadID : SV_DispatchThreadID)
|
||||
|
|
|
@ -7,14 +7,14 @@ void main(int3 ThreadID : SV_DispatchThreadID, int3 gThreadID : SV_GroupThreadID
|
|||
if(gThreadID.y < blurRadius)
|
||||
{
|
||||
int y = max(ThreadID.y-blurRadius,0);
|
||||
gCache[gThreadID.y] = inTex[int2(ThreadID.x,y)];
|
||||
gCache[gThreadID.y] = inTex[min(int2(ThreadID.x,y) + Start, Stop-1)];
|
||||
}
|
||||
if(gThreadID.y >= N-blurRadius)
|
||||
{
|
||||
int y = min(ThreadID.y+blurRadius,inTex.Length.y-1);
|
||||
gCache[gThreadID.y+2*blurRadius] = inTex[int2(ThreadID.x,y)];
|
||||
int y = min(ThreadID.y+blurRadius, Stop.y-1);
|
||||
gCache[gThreadID.y+2*blurRadius] = inTex[int2(ThreadID.x,y) + Start];
|
||||
}
|
||||
gCache[gThreadID.y+blurRadius] = inTex[min(ThreadID.xy,inTex.Length.xy-1)];
|
||||
gCache[gThreadID.y+blurRadius] = inTex[min(ThreadID.xy + Start, Stop.xy-1)];
|
||||
|
||||
GroupMemoryBarrierWithGroupSync();
|
||||
|
||||
|
@ -27,6 +27,6 @@ void main(int3 ThreadID : SV_DispatchThreadID, int3 gThreadID : SV_GroupThreadID
|
|||
blurCol +=Weights[i + blurRadius] * gCache[k];
|
||||
}
|
||||
|
||||
outTex[ThreadID.xy] = blurCol;
|
||||
//Output[ThreadID.xy] = inTex[((ThreadID.xy))];
|
||||
outTex[ThreadID.xy + Start] = blurCol + inTex[ThreadID.xy + Start] * ( float4(1,1,1,1) - BlurMask);;
|
||||
//outTex[ThreadID.xy] = inTex[ThreadID.xy];
|
||||
}
|
|
@ -1,9 +1,51 @@
|
|||
#include "Header.hlsli"
|
||||
|
||||
|
||||
|
||||
float3x3 cotangent_frame( float3 N, float3 p, float2 uv )
|
||||
{
|
||||
// get edge vectors of the pixel triangle
|
||||
float3 dp1 = ddx( p );
|
||||
float3 dp2 = ddy( p );
|
||||
float2 duv1 = ddx( uv );
|
||||
float2 duv2 = ddy( uv );
|
||||
|
||||
// solve the linear system
|
||||
float3 dp2perp = cross( dp2, N );
|
||||
float3 dp1perp = cross( N, dp1 );
|
||||
float3 T = dp2perp * duv1.x + dp1perp * duv2.x;
|
||||
float3 B = dp2perp * duv1.y + dp1perp * duv2.y;
|
||||
|
||||
// construct a scale-invariant frame
|
||||
float invmax = 1/sqrt( max( dot(T,T), dot(B,B) ) );
|
||||
return float3x3( T * invmax, B * invmax, N );
|
||||
}
|
||||
|
||||
float3 perturb_normal( float3 N, float3 V, float2 texcoord )
|
||||
{
|
||||
// assume N, the interpolated vertex normal and
|
||||
// V, the view vector (vertex to eye)
|
||||
float3 map = Normal.Sample(S1,texcoord).xyz;
|
||||
map = map * 255./127. - 128./127.;
|
||||
#ifdef WITH_NORMALMAP_2CHANNEL
|
||||
map.z = sqrt( 1. - dot( map.xy, map.xy ) );
|
||||
#endif
|
||||
#ifdef WITH_NORMALMAP_GREEN_UP
|
||||
map.y = -map.y;
|
||||
#endif
|
||||
float3x3 TBN = cotangent_frame( N, -V, texcoord );
|
||||
return normalize( mul(transpose(TBN), map) );
|
||||
}
|
||||
|
||||
PixelOut main(VertexOut input)
|
||||
{
|
||||
PixelOut output;
|
||||
output.DiffuseGlow = Diffuse.Sample(S1, input.UV);
|
||||
output.NormalSpec = float4(normalize(input.normal), Normal.Sample(S1,input.UV).w);
|
||||
output.DiffuseGlow = Diffuse.Sample(S1, input.UV) * float4(Color, 1);
|
||||
float3 normal = normalize(input.normal);
|
||||
|
||||
normal = perturb_normal( normal, normalize(-input.ViewPos), input.UV );
|
||||
|
||||
//output.NormalSpec = float4(normal, Normal.Sample(S1, input.UV).w*255);
|
||||
output.NormalSpec = float4(normal, Normal.Sample(S1, input.UV).w*0);
|
||||
return output;
|
||||
}
|
|
@ -14,6 +14,7 @@ VertexOut main( VertexIn input )
|
|||
input.normal = mul(boneTrans,float4(input.normal,1)).xyz * Animated + input.normal * int(1-Animated);
|
||||
|
||||
output.pos = mul(WVP, float4(input.pos,1));
|
||||
output.ViewPos = mul(WV, float4(input.pos,1));
|
||||
output.normal = mul(WV, float4(input.normal,0)).xyz;
|
||||
output.UV = input.UV;
|
||||
return output;
|
||||
|
|
|
@ -12,7 +12,7 @@ struct VertexIn
|
|||
struct VertexOut
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
//float4 ViewPos : POSITION;
|
||||
float4 ViewPos : POSITION;
|
||||
float2 UV : TEXCOORD;
|
||||
float3 normal : NORMAL;
|
||||
//float3 tangent : TANGENT;
|
||||
|
@ -41,4 +41,9 @@ cbuffer PerModel : register(b1)
|
|||
matrix WVP;
|
||||
int Animated;
|
||||
float3 Pad;
|
||||
}
|
||||
|
||||
cbuffer Tint : register(b0)
|
||||
{
|
||||
float3 Color;
|
||||
}
|
|
@ -24,5 +24,7 @@ DiffSpec LightCalc(PointLight pl, float3 pos, int2 texCoord)
|
|||
output.Diffuse = float3(0,0,0);
|
||||
output.Specular = float3(0,0,0);
|
||||
}
|
||||
float SpecCo = normalSpec.w < 1 ? 0.0f : 1.0f;
|
||||
output.Specular = output.Specular * SpecCo;
|
||||
return output;
|
||||
}
|
|
@ -36,7 +36,7 @@ void main( uint3 DTid : SV_DispatchThreadID, uint3 GTid : SV_GroupThreadID )
|
|||
float AmbValue = GetSSAO(ViewPos, UV, DTid.xy, GTid.xy/2);
|
||||
Ambient[DTid.xy/2] = float4(DiffuseGlow[DTid.xy].xyz, AmbValue);
|
||||
Ambient[DTid.xy/2 + float2(Pixels.x/2, 0)] = GUI[DTid.xy];
|
||||
//Ambient[DTid.xy] = GUI[DTid.xy];
|
||||
Ambient[DTid.xy/2 + float2(0, Pixels.y/2)] = float4(DiffuseGlow[DTid.xy].xyz * DiffuseGlow[DTid.xy].w*10,1);
|
||||
}
|
||||
|
||||
}
|
|
@ -4,6 +4,8 @@ Texture2D Ambient : register(t2);
|
|||
|
||||
RWTexture2D<float4> Output;
|
||||
|
||||
SamplerState S1 : register(s0);
|
||||
|
||||
cbuffer Size : register(b0)
|
||||
{
|
||||
int2 Pixels;
|
||||
|
@ -11,16 +13,40 @@ cbuffer Size : register(b0)
|
|||
|
||||
#define AmbFactor 0.8f;
|
||||
|
||||
float4 SuperSample(float4 Glow, uint3 DTid)
|
||||
{
|
||||
// Line X
|
||||
float2 index = (float2)(DTid.xy/2);
|
||||
index += float2(0,Output.Length.y/2);
|
||||
index = index / Output.Length;
|
||||
Glow = Ambient.SampleLevel(S1, index,1);
|
||||
//Line Y+1
|
||||
//Glow += Ambient[DTid.xy/2 + uint2(1,(Output.Length.y/2)+1)] + Ambient[DTid.xy/2 + uint2(0,(Output.Length.y/2)+1)] + Ambient[DTid.xy/2 + uint2(-1,(Output.Length.y/2)+1)];
|
||||
//Line Y-1
|
||||
//Glow += Ambient[DTid.xy/2 + uint2(1,(Output.Length.y/2)-1)] + Ambient[DTid.xy/2 + uint2(0,(Output.Length.y/2)-1)] + Ambient[DTid.xy/2 + uint2(-1,(Output.Length.y/2)-1)];
|
||||
|
||||
//Glow = Glow/9;
|
||||
|
||||
return Glow;
|
||||
}
|
||||
|
||||
[numthreads(16, 16, 1)]
|
||||
void main( uint3 DTid : SV_DispatchThreadID )
|
||||
{
|
||||
float4 Light = Diffuse[DTid.xy] + saturate(Specular[DTid.xy]);
|
||||
float4 Amb = float4(Ambient[DTid.xy/2].xyz * Ambient[DTid.xy/2].w, 0);
|
||||
float4 Amb = float4(Ambient[DTid.xy/2].xyz/* * Ambient[DTid.xy/2].w */, 0);
|
||||
//float4 Glow = Ambient[DTid.xy/2 + uint2(0,Output.Length.y/2)];
|
||||
float4 Glow = Ambient[DTid.xy/2 + uint2(0,Output.Length.y/2)];
|
||||
|
||||
Glow = SuperSample(Glow,DTid);
|
||||
|
||||
float4 GUI;
|
||||
uint2 index = DTid.xy/2 + uint2(Pixels.x/2,0);
|
||||
uint2 index = DTid.xy/2 + uint2((uint)Pixels.x/(uint)2,0);
|
||||
float3 PostLight = Amb.xyz * AmbFactor;
|
||||
PostLight = PostLight + Light.xyz;
|
||||
PostLight = PostLight + Light.xyz; // + Glow;
|
||||
GUI = float4(Ambient[index]);
|
||||
PostLight = PostLight * (1 - GUI.w);
|
||||
Output[DTid.xy] = float4((GUI.xyz * GUI.w) + PostLight, 1);
|
||||
|
||||
//Output[DTid.xy] = Glow;
|
||||
}
|
|
@ -171,13 +171,16 @@ HRESULT InitDirect3D()
|
|||
}
|
||||
|
||||
m = Oyster::Graphics::API::CreateModel(L"crate_colonists.dan");
|
||||
m->WorldMatrix.m[0][0] = 50;
|
||||
m->WorldMatrix.m[1][1] = 50;
|
||||
m->WorldMatrix.m[2][2] = 0.00000005f;
|
||||
//m->WorldMatrix.m[0][0] = 50;
|
||||
//m->WorldMatrix.m[1][1] = 50;
|
||||
//m->WorldMatrix.m[2][2] = 0.00000005f;
|
||||
m2 = Oyster::Graphics::API::CreateModel(L"char_temporary.dan");
|
||||
m2->Tint = Oyster::Math::Float3(0.1f,0.1f,1);
|
||||
m3 = Oyster::Graphics::API::CreateModel(L"char_temporary.dan");
|
||||
m2->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3::null,Oyster::Math::Float3(4,0,0),Oyster::Math::Float3::null);
|
||||
Oyster::Graphics::API::PlayAnimation(m2, L"movement",false);
|
||||
|
||||
Oyster::Graphics::API::PlayAnimation(m2, L"movement", true);
|
||||
Oyster::Graphics::API::PlayAnimation(m3, L"movement", true);
|
||||
|
||||
t = Oyster::Graphics::API::CreateTexture(L"structure_corp_mdg.png");
|
||||
t2 = Oyster::Graphics::API::CreateTexture(L"whiteGui.png");
|
||||
|
||||
|
@ -189,22 +192,22 @@ HRESULT InitDirect3D()
|
|||
|
||||
|
||||
|
||||
pl.Color = Oyster::Math::Float3(1,0,0);
|
||||
pl.Bright = 1;
|
||||
pl.Color = Oyster::Math::Float3(1,1,1);
|
||||
pl.Bright = 0.5f;
|
||||
pl.Pos = Oyster::Math::Float3(-20,0,0);
|
||||
pl.Radius = 90;
|
||||
|
||||
Oyster::Graphics::API::AddLight(pl);
|
||||
|
||||
pl.Color = Oyster::Math::Float3(0,1,0);
|
||||
pl.Bright = 1;
|
||||
pl.Color = Oyster::Math::Float3(1,1,1);
|
||||
pl.Bright = 0.5f;
|
||||
pl.Pos = Oyster::Math::Float3(0,20,0);
|
||||
pl.Radius = 90;
|
||||
|
||||
Oyster::Graphics::API::AddLight(pl);
|
||||
|
||||
pl.Color = Oyster::Math::Float3(0,0,1);
|
||||
pl.Bright = 1;
|
||||
pl.Color = Oyster::Math::Float3(1,1,1);
|
||||
pl.Bright = 0.5f;
|
||||
pl.Pos = Oyster::Math::Float3(0,0,20);
|
||||
pl.Radius = 90;
|
||||
|
||||
|
@ -217,7 +220,9 @@ float angle = 0;
|
|||
HRESULT Update(float deltaTime)
|
||||
{
|
||||
//angle += Oyster::Math::pi/16 * deltaTime;
|
||||
m->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3(1,0,0) * angle,Oyster::Math::Float3(0,0,0),Oyster::Math::Float3::null);
|
||||
m2->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3(0,1,0) * angle,Oyster::Math::Float3(4,0,0),Oyster::Math::Float3::null);
|
||||
m3->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3(0,1,0) * -angle,Oyster::Math::Float3(-4,0,0),Oyster::Math::Float3::null);
|
||||
//Oyster::Math::Matrix ma = Oyster::Math::Matrix::identity;
|
||||
Oyster::Graphics::API::Update(deltaTime);
|
||||
//m2->Animation.data.AnimationTime += deltaTime;// * 0.5f;
|
||||
|
@ -231,16 +236,17 @@ HRESULT Render(float deltaTime)
|
|||
|
||||
Oyster::Graphics::API::RenderModel(m);
|
||||
Oyster::Graphics::API::RenderModel(m2);
|
||||
Oyster::Graphics::API::RenderModel(m3);
|
||||
Oyster::Graphics::API::StartGuiRender();
|
||||
Oyster::Graphics::API::RenderGuiElement(t,Oyster::Math::Float2(0.5f,0.5f),Oyster::Math::Float2(1,1));
|
||||
//Oyster::Graphics::API::RenderGuiElement(t2,Oyster::Math::Float2(0.5f,0.1f),Oyster::Math::Float2(0.5f,0.1f),Oyster::Math::Float3(1,0,0));
|
||||
//Oyster::Graphics::API::RenderGuiElement(t,Oyster::Math::Float2(0.5f,0.5f),Oyster::Math::Float2(1,1), Oyster::Math::Float3(0,0,1));
|
||||
//Oyster::Graphics::API::RenderGuiElement(t2,Oyster::Math::Float2(0.5f,0.5f),Oyster::Math::Float2(1,1),Oyster::Math::Float3(1,0,0));
|
||||
Oyster::Graphics::API::StartTextRender();
|
||||
std::wstring fps;
|
||||
float f = 1/deltaTime;
|
||||
fps = std::to_wstring(f);
|
||||
//Oyster::Graphics::API::RenderText(L"Lanariel",Oyster::Math::Float2(0.5f,0.1f),Oyster::Math::Float2(0.5f,0.1f));
|
||||
//Oyster::Graphics::API::RenderText(L"Lanariel WAS HERE",Oyster::Math::Float2(0.5f,0.1f),Oyster::Math::Float2(0.5f,0.1f));
|
||||
Oyster::Graphics::API::RenderText(fps,Oyster::Math::Float2(0.5f,0.1f),Oyster::Math::Float2(0.5f,0.1f),Oyster::Math::Float3(0,1,0));
|
||||
Oyster::Graphics::API::RenderText(fps,Oyster::Math::Float3(0.5f,0.1f,1.0f),Oyster::Math::Float2(0.5f,0.1f), 0.08f, Oyster::Math::Float3(0,1,0));
|
||||
Oyster::Graphics::API::EndFrame();
|
||||
|
||||
return S_OK;
|
||||
|
|
Loading…
Reference in New Issue