Merge branch 'master' of github.com:teamfisk/AgileBreakOut into Tobias
This commit is contained in:
+41
-20
@@ -53,6 +53,16 @@ file(GLOB SOURCE_FILES_Rendering
|
||||
"Rendering/*.cpp"
|
||||
)
|
||||
source_group(Rendering FILES ${SOURCE_FILES_Rendering})
|
||||
file(GLOB SOURCE_FILES_Rendering_OpenGL
|
||||
"${INCLUDE_PATH}/Rendering/OpenGL/Rendering/*.h"
|
||||
"Rendering/OpenGL/*.cpp"
|
||||
)
|
||||
source_group(Rendering\\OpenGL FILES ${SOURCE_FILES_Rendering_OpenGL})
|
||||
file(GLOB SOURCE_FILES_Rendering_DirectX
|
||||
"${INCLUDE_PATH}/Rendering/DirectX/Rendering/*.h"
|
||||
"Rendering/DirectX/*.cpp"
|
||||
)
|
||||
source_group(Rendering\\DirectX FILES ${SOURCE_FILES_Rendering_DirectX})
|
||||
|
||||
file(GLOB SOURCE_FILES_Transform
|
||||
"${INCLUDE_PATH}/Transform/*.h"
|
||||
@@ -61,8 +71,8 @@ file(GLOB SOURCE_FILES_Transform
|
||||
source_group(Transform FILES ${SOURCE_FILES_Transform})
|
||||
|
||||
file(GLOB SOURCE_FILES_Physics
|
||||
"${INCLUDE_PATH}/Physics/*.h"
|
||||
"Physics/*.cpp"
|
||||
"${INCLUDE_PATH}/Physics/*.h"
|
||||
"Physics/*.cpp"
|
||||
)
|
||||
source_group(Physics FILES ${SOURCE_FILES_Physics})
|
||||
|
||||
@@ -102,14 +112,7 @@ set(SOURCE_FILES
|
||||
${SOURCE_FILES_GUI}
|
||||
)
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w")
|
||||
set(STATIC_LIBRARY_FLAGS "${STATIC_LIBRARY_FLAGS}")
|
||||
endif()
|
||||
|
||||
add_library(game ${SOURCE_FILES})
|
||||
target_link_libraries(game
|
||||
set(LIBRARIES
|
||||
${OPENGL_LIBRARIES}
|
||||
${GLEW_LIBRARIES}
|
||||
${GLFW_LIBRARIES}
|
||||
@@ -118,7 +121,33 @@ target_link_libraries(game
|
||||
${PNG_LIBRARIES}
|
||||
${X11_LIBRARIES}
|
||||
${OPENAL_LIBRARY}
|
||||
${liquidfun_LIBRARIES}
|
||||
${liquidfun_LIBRARIES}
|
||||
)
|
||||
|
||||
if(BUILD_RENDERER_OPENGL)
|
||||
set(SOURCE_FILES ${SOURCE_FILES}
|
||||
${SOURCE_FILES_Rendering_OpenGL}
|
||||
)
|
||||
endif()
|
||||
# Compiling for DirectX target
|
||||
if(BUILD_RENDERER_DIRECTX)
|
||||
set(SOURCE_FILES ${SOURCE_FILES}
|
||||
${SOURCE_FILES_Rendering_DirectX}
|
||||
)
|
||||
set(LIBRARIES ${LIBRARIES}
|
||||
${CMAKE_LIBRARY_PATH}/DirectXTK.lib
|
||||
)
|
||||
endif()
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w")
|
||||
set(STATIC_LIBRARY_FLAGS "${STATIC_LIBRARY_FLAGS}")
|
||||
endif()
|
||||
|
||||
add_library(game ${SOURCE_FILES})
|
||||
target_link_libraries(game
|
||||
${LIBRARIES}
|
||||
)
|
||||
|
||||
add_executable(breakout
|
||||
@@ -126,14 +155,6 @@ add_executable(breakout
|
||||
)
|
||||
target_link_libraries(breakout
|
||||
game
|
||||
${OPENGL_LIBRARIES}
|
||||
${GLEW_LIBRARIES}
|
||||
${GLFW_LIBRARIES}
|
||||
${Boost_LIBRARIES}
|
||||
${assimp_LIBRARIES}
|
||||
${PNG_LIBRARIES}
|
||||
${X11_LIBRARIES}
|
||||
${OPENAL_LIBRARY}
|
||||
${liquidfun_LIBRARIES}
|
||||
${LIBRARIES}
|
||||
)
|
||||
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "Core/BGFXRenderer.h"
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
This file is part of Daydream Engine.
|
||||
Copyright 2014 Adam Byléhn, Tobias Dahl, Simon Holmberg, Viktor Ljung
|
||||
|
||||
Daydream Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Daydream Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Daydream Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "Core/StaticSystem.h"
|
||||
|
||||
std::unordered_map<size_t, void*> dd::StaticSystem::Instances;
|
||||
@@ -11,8 +11,11 @@ void dd::Systems::KrakenSystem::Initialize()
|
||||
m_RandomGenerator = std::mt19937(rd());
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPause, &KrakenSystem::OnPause);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EResume, &KrakenSystem::OnResume);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EContact, &KrakenSystem::OnContact);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EKrakenAppear, &KrakenSystem::OnKrakenAppear);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EKrakenAttack, &KrakenSystem::OnKrakenAttack);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EKrakenHit, &KrakenSystem::OnKrakenHit);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EKrakenDefeated, &KrakenSystem::OnKrakenDefeated);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EBrickGenerating, &KrakenSystem::OnBrickGenerating);
|
||||
|
||||
EntityID ent = m_World->CreateEntity();
|
||||
@@ -59,7 +62,7 @@ void dd::Systems::KrakenSystem::Update(double dt)
|
||||
|
||||
void dd::Systems::KrakenSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
||||
{
|
||||
if (IsPaused()) {
|
||||
if (IsPaused() || !m_KrakenBattle) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -68,6 +71,11 @@ void dd::Systems::KrakenSystem::UpdateEntity(double dt, EntityID entity, EntityI
|
||||
|
||||
auto kraken = m_World->GetComponent<Components::Kraken>(entity);
|
||||
if (kraken != nullptr) {
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
if (transform->Position.y < -10) {
|
||||
m_World->RemoveEntity(entity);
|
||||
return;
|
||||
}
|
||||
Events::KrakenAttack krakenAttack;
|
||||
switch (kraken->CurrentAction)
|
||||
{
|
||||
@@ -77,9 +85,9 @@ void dd::Systems::KrakenSystem::UpdateEntity(double dt, EntityID entity, EntityI
|
||||
m_KrakenTimer = 0;
|
||||
std::uniform_real_distribution<float> dist(1, 2.999f);
|
||||
float random = dist(m_RandomGenerator);
|
||||
std::cout << random << std::endl;
|
||||
//std::cout << random << std::endl;
|
||||
kraken->CurrentAction = random;
|
||||
std::cout << kraken->CurrentAction << std::endl;
|
||||
//std::cout << kraken->CurrentAction << std::endl;
|
||||
}
|
||||
break;
|
||||
case 2: // Grabbing
|
||||
@@ -126,6 +134,42 @@ bool dd::Systems::KrakenSystem::OnResume(const dd::Events::Resume &event)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::KrakenSystem::OnContact(const dd::Events::Contact &event)
|
||||
{
|
||||
Components::Kraken* kraken1 = m_World->GetComponent<Components::Kraken>(event.Entity1);
|
||||
Components::Kraken* kraken2 = m_World->GetComponent<Components::Kraken>(event.Entity2);
|
||||
Components::Kraken* kraken;
|
||||
|
||||
if (kraken1 != nullptr && kraken2 != nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
EntityID krakenEntity, otherEntitiy;
|
||||
|
||||
//Which is the ball?
|
||||
if (kraken1 != nullptr) {
|
||||
krakenEntity = event.Entity1;
|
||||
otherEntitiy = event.Entity2;
|
||||
kraken = kraken1;
|
||||
}
|
||||
else if (kraken2 != nullptr) {
|
||||
krakenEntity = event.Entity2;
|
||||
otherEntitiy = event.Entity1;
|
||||
kraken = kraken2;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto ball = m_World->GetComponent<Components::Ball>(otherEntitiy);
|
||||
if (ball != nullptr) {
|
||||
Events::KrakenHit e;
|
||||
e.Kraken = krakenEntity;
|
||||
e.Hitter = otherEntitiy;
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
}
|
||||
|
||||
bool dd::Systems::KrakenSystem::OnKrakenAppear(const dd::Events::KrakenAppear &event)
|
||||
{
|
||||
auto ent = m_World->CloneEntity(m_KrakenTemplate);
|
||||
@@ -144,6 +188,103 @@ bool dd::Systems::KrakenSystem::OnKrakenAttack(const dd::Events::KrakenAttack &e
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::KrakenSystem::OnKrakenHit(const dd::Events::KrakenHit &event)
|
||||
{
|
||||
auto kraken = m_World->GetComponent<Components::Kraken>(event.Kraken);
|
||||
//kraken->Health--;
|
||||
//std::cout << kraken->Health << std::endl;
|
||||
kraken->Health = -1;
|
||||
if (kraken->Health < 0) {
|
||||
Events::KrakenDefeated e;
|
||||
e.Kraken = event.Kraken;
|
||||
e.Hitter = event.Hitter;
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool dd::Systems::KrakenSystem::OnKrakenDefeated(const dd::Events::KrakenDefeated &event)
|
||||
{
|
||||
m_KrakenBattle = false;
|
||||
|
||||
auto kraken = m_World->GetComponent<Components::Kraken>(event.Kraken);
|
||||
auto physicsComponent = m_World->GetComponent<Components::Physics>(event.Kraken);
|
||||
/*physicsComponent->CollisionType = CollisionType::Type::Dynamic;
|
||||
physicsComponent->GravityScale = 1.f;
|
||||
physicsComponent->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Water | CollisionLayer::Wall);
|
||||
physicsComponent->Calculate = false;*/
|
||||
|
||||
auto transformComponentBrick = m_World->GetComponent<Components::Transform>(event.Kraken);
|
||||
auto transformComponentHitter = m_World->GetComponent<Components::Transform>(event.Hitter);
|
||||
|
||||
|
||||
auto brickModel = m_World->GetComponent<Components::Model>(event.Kraken);
|
||||
|
||||
auto cTransform = m_World->GetComponent<Components::Transform>(event.Kraken);
|
||||
/*cTransform->Position = cTransform->Position + transformComponentBrick->Position;
|
||||
glm::vec2 ballToBrick = 4.f * glm::normalize(glm::vec2(cTransform->Position.x - transformComponentHitter->Position.x, cTransform->Position.y - transformComponentHitter->Position.y));
|
||||
cTransform->Velocity = glm::vec3(ballToBrick.x, ballToBrick.y, 0.f);
|
||||
|
||||
std::uniform_real_distribution<float> dist(-1.5f, 1.5f);
|
||||
int impulseStrength = dist(m_RandomGenerator);
|
||||
|
||||
Events::SetImpulse i;
|
||||
i.Entity = event.Kraken;
|
||||
i.Impulse = glm::vec2(impulseStrength, 0.f);
|
||||
i.Point = glm::vec2(cTransform->Position.x, cTransform->Position.y + 0.5f);
|
||||
EventBroker->Publish(i);*/
|
||||
|
||||
auto cModel = m_World->GetComponent<Components::Model>(event.Kraken);
|
||||
cModel->Color = brickModel->Color;
|
||||
cModel->Color *= 0.5f;
|
||||
|
||||
/*m_World->RemoveComponent<Components::Template>(event.Kraken);
|
||||
m_World->SetEntityParent(event.Kraken, 0);
|
||||
m_World->CommitEntity(event.Kraken);*/
|
||||
|
||||
//Particle trail
|
||||
Events::CreateParticleSequence trail;
|
||||
trail.parent = event.Kraken;
|
||||
trail.AlphaValues.push_back(1.f);
|
||||
trail.AlphaValues.push_back(0.f);
|
||||
trail.ScaleValues.push_back(glm::vec3(0.08f));
|
||||
trail.ScaleValues.push_back(glm::vec3(0.f));
|
||||
trail.RadiusDistribution = 1;
|
||||
trail.EmitterLifeTime = 2.f;
|
||||
trail.ParticleLifeTime = 1.f;
|
||||
trail.ParticlesPerTick = 1;
|
||||
trail.SpawnRate = 0.1f;
|
||||
trail.Speed = 10.f;
|
||||
trail.EmittingAngle = glm::half_pi<float>();
|
||||
trail.SpriteFile = "Textures/Particles/FadeBall.png";
|
||||
trail.Color = brickModel->Color;
|
||||
//p.Spread = ...
|
||||
EventBroker->Publish(trail);
|
||||
|
||||
//ParticlePoof
|
||||
Events::CreateParticleSequence poof;
|
||||
poof.EmitterLifeTime = 4;
|
||||
poof.EmittingAngle = glm::half_pi<float>();
|
||||
poof.Spread = 0.5f;
|
||||
poof.NumberOfTicks = 1;
|
||||
poof.ParticleLifeTime = 1.5f;
|
||||
poof.ParticlesPerTick = 1;
|
||||
poof.Position = cTransform->Position;
|
||||
poof.ScaleValues.clear();
|
||||
poof.ScaleValues.push_back(glm::vec3(0.5f));
|
||||
poof.ScaleValues.push_back(glm::vec3(2.f, 2.f, 0.2f));
|
||||
poof.SpriteFile = "Textures/Particles/Cloud_Particle.png";
|
||||
poof.Color = brickModel->Color;
|
||||
poof.AlphaValues.clear();
|
||||
poof.AlphaValues.push_back(1.f);
|
||||
poof.AlphaValues.push_back(0.f);
|
||||
poof.Speed = 10;
|
||||
EventBroker->Publish(poof);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::KrakenSystem::OnBrickGenerating(const dd::Events::BrickGenerating &event)
|
||||
{
|
||||
return true;
|
||||
|
||||
@@ -18,10 +18,12 @@ void dd::Systems::LevelSystem::Initialize()
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EMultiBallLost, &LevelSystem::OnMultiBallLost);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPowerUpTaken, &LevelSystem::OnPowerUpTaken);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EStageCleared, &LevelSystem::OnStageCleared);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EArrivedAtNewStage, &LevelSystem::OnArrivedAtNewStage);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPause, &LevelSystem::OnPause);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EResume, &LevelSystem::OnResume);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EHitPad, &LevelSystem::OnHitPad);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EBrickGenerating, &LevelSystem::OnBrickGenerating);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EKrakenDefeated, &LevelSystem::OnKrakenDefeated);
|
||||
|
||||
m_GodMode = ResourceManager::Load<ConfigFile>("Config.ini")->GetValue("Cheat.GodMode", false);
|
||||
|
||||
@@ -60,7 +62,7 @@ void dd::Systems::LevelSystem::Initialize()
|
||||
travels->CurrentlyTraveling = false;
|
||||
auto model = m_World->AddComponent<Components::Model>(t_halfPipe);
|
||||
model->ModelFile = "Models/Test/halfpipe/Halfpipe.obj";
|
||||
model->Color = glm::vec4(0.8f, 0.8f, 0.8f, 0.3f);
|
||||
model->Color = glm::vec4(0.8f, 0.8f, 0.8f, 1.f);
|
||||
m_World->CommitEntity(t_halfPipe);
|
||||
|
||||
auto t_halfPipe2 = m_World->CloneEntity(t_halfPipe);
|
||||
@@ -84,16 +86,7 @@ void dd::Systems::LevelSystem::Initialize()
|
||||
}*/
|
||||
|
||||
// auto particleEmitter= m_World->AddComponent<Components::Emitter>(Pe);
|
||||
//Water test
|
||||
{
|
||||
auto t_waterBody = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(t_waterBody);
|
||||
transform->Position = glm::vec3(0.f, -3.5f, -10.f);
|
||||
transform->Scale = glm::vec3(7.0f, 1.5f, 1.f);
|
||||
auto water = m_World->AddComponent<Components::WaterVolume>(t_waterBody);
|
||||
auto body = m_World->AddComponent<Components::RectangleShape>(t_waterBody);
|
||||
m_World->CommitEntity(t_waterBody);
|
||||
}
|
||||
|
||||
|
||||
//ParticleTest
|
||||
|
||||
@@ -114,7 +107,7 @@ void dd::Systems::LevelSystem::Initialize()
|
||||
particleEmitter->Spread = glm::pi<float>()*2;
|
||||
particleEmitter->EmittingAngle = glm::pi<float>();
|
||||
particleEmitter->LifeTime = 50;
|
||||
|
||||
|
||||
{
|
||||
auto Pt = m_World->CreateEntity(Pe);
|
||||
auto PtTransform = m_World->AddComponent<Components::Transform>(Pt);
|
||||
@@ -134,13 +127,13 @@ void dd::Systems::LevelSystem::Initialize()
|
||||
//TODO: Why does the ball not collide with these bricks?
|
||||
//BottomBox
|
||||
{
|
||||
auto BottomWall = m_World->CreateEntity();
|
||||
EntityID BottomWall = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(BottomWall);
|
||||
auto wall = m_World->AddComponent<Components::Wall>(BottomWall);
|
||||
transform->Position = glm::vec3(0.f, -6.f, -10.f);
|
||||
transform->Scale = glm::vec3(20.f, 0.5f, 1.f);
|
||||
//std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(BottomWall);
|
||||
//sprite->SpriteFile = "Textures/Core/ErrorTexture.png";
|
||||
std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(BottomWall);
|
||||
sprite->SpriteFile = "Textures/Core/ErrorTexture.png";
|
||||
std::shared_ptr<Components::RectangleShape> rectangleShape = m_World->AddComponent<Components::RectangleShape>(BottomWall);
|
||||
rectangleShape->Dimensions = glm::vec2(20.f, 0.5f);
|
||||
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(BottomWall);
|
||||
@@ -152,6 +145,8 @@ void dd::Systems::LevelSystem::Initialize()
|
||||
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::LifeBuoy);
|
||||
}
|
||||
m_World->CommitEntity(BottomWall);
|
||||
|
||||
m_World->SetProperty(BottomWall, "Name", "BottomWall");
|
||||
}
|
||||
|
||||
{
|
||||
@@ -301,6 +296,7 @@ void dd::Systems::LevelSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
||||
} else if (brick->Type == InkBlasterBrick) {
|
||||
Events::InkBlaster e;
|
||||
e.Shots = 5;
|
||||
e.Speed = 7;
|
||||
EventBroker->Publish(e);
|
||||
} else if(brick->Type == KrakenAttackBrick) {
|
||||
Events::KrakenAttack e;
|
||||
@@ -321,6 +317,7 @@ void dd::Systems::LevelSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
||||
Events::StageCleared ec;
|
||||
ec.ClearedStage = m_CurrentLevel;
|
||||
ec.StageCluster = m_CurrentCluster;
|
||||
ec.StagesInCluster = m_StagesInCluster;
|
||||
EventBroker->Publish(ec);
|
||||
} else {
|
||||
if (ball != nullptr && MultiBalls() > 0) {
|
||||
@@ -443,7 +440,7 @@ EntityID dd::Systems::LevelSystem::CreateBrick(int row, int line, glm::vec2 spac
|
||||
} else if (typeInt == KrakenAttackBrick) {
|
||||
cBrick->Type = KrakenAttackBrick;
|
||||
auto type = m_World->AddComponent<Components::KrakenAttackBrick>(brick);
|
||||
model->Color = glm::vec4(0.f, 0.5f, 1.0f, .0f);
|
||||
model->Color = glm::vec4(0.f, 0.5f, 1.0f, 1.0f);
|
||||
} else if (typeInt == Kraken) {
|
||||
Events::KrakenAppear e;
|
||||
e.Position = transform->Position;
|
||||
@@ -509,14 +506,14 @@ void dd::Systems::LevelSystem::GetBrickSet(int set)
|
||||
// m is magenta.
|
||||
// d is dark.
|
||||
// Feel free to make your own.
|
||||
glm::vec4 w = glm::vec4(1, 1, 1, 0);
|
||||
glm::vec4 r = glm::vec4(1, 0, 0, 0);
|
||||
glm::vec4 g = glm::vec4(0, 1, 0, 0);
|
||||
glm::vec4 b = glm::vec4(0, 0, 1, 0);
|
||||
glm::vec4 y = glm::vec4(1, 1, 0, 0);
|
||||
glm::vec4 c = glm::vec4(0, 1, 1, 0);
|
||||
glm::vec4 m = glm::vec4(1, 0, 1, 0);
|
||||
glm::vec4 d = glm::vec4(0, 0, 0, 0);
|
||||
glm::vec4 w = glm::vec4(1, 1, 1, 1);
|
||||
glm::vec4 r = glm::vec4(1, 0, 0, 1);
|
||||
glm::vec4 g = glm::vec4(0, 1, 0, 1);
|
||||
glm::vec4 b = glm::vec4(0, 0, 1, 1);
|
||||
glm::vec4 y = glm::vec4(1, 1, 0, 1);
|
||||
glm::vec4 c = glm::vec4(0, 1, 1, 1);
|
||||
glm::vec4 m = glm::vec4(1, 0, 1, 1);
|
||||
glm::vec4 d = glm::vec4(0, 0, 0, 1);
|
||||
|
||||
if (set == 1) {
|
||||
level =
|
||||
@@ -688,6 +685,7 @@ void dd::Systems::LevelSystem::BrickHit(EntityID entityHitter, EntityID entityBr
|
||||
Events::InkBlaster e;
|
||||
e.Transform = transformComponentBrick;
|
||||
e.Shots = 5;
|
||||
e.Speed = 7;
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
else {
|
||||
@@ -710,8 +708,6 @@ void dd::Systems::LevelSystem::BrickHit(EntityID entityHitter, EntityID entityBr
|
||||
auto brickChildren = m_World->GetEntityChildren(entityBrick);
|
||||
for (auto b : brickChildren)
|
||||
{
|
||||
|
||||
|
||||
auto cTransform = m_World->GetComponent<Components::Transform>(b);
|
||||
cTransform->Position = cTransform->Position + transformComponentBrick->Position;
|
||||
glm::vec2 ballToBrick = 4.f * glm::normalize(glm::vec2(cTransform->Position.x - transformComponentHitter->Position.x, cTransform->Position.y - transformComponentHitter->Position.y));
|
||||
@@ -837,6 +833,16 @@ bool dd::Systems::LevelSystem::OnPowerUpTaken(const dd::Events::PowerUpTaken &ev
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::LevelSystem::OnKrakenDefeated(const dd::Events::KrakenDefeated &event)
|
||||
{
|
||||
SetNumberOfBricks(NumberOfBricks() - 1);
|
||||
m_LooseBricks--;
|
||||
|
||||
std::cout << m_LooseBricks << std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::LevelSystem::OnStageCleared(const dd::Events::StageCleared &event)
|
||||
{
|
||||
if (!m_Cleared) {
|
||||
@@ -848,12 +854,13 @@ bool dd::Systems::LevelSystem::OnStageCleared(const dd::Events::StageCleared &ev
|
||||
es.Score = 500;
|
||||
EventBroker->Publish(es);
|
||||
m_CurrentLevel++;
|
||||
if (m_CurrentLevel < 6) {
|
||||
if (m_CurrentLevel <= event.StagesInCluster) {
|
||||
GetNextLevel();
|
||||
CreateLevel(12); //NextLevelDistance
|
||||
} else {
|
||||
// Win
|
||||
Events::ClusterClear e;
|
||||
e.ClusterCleared = m_CurrentCluster;
|
||||
EventBroker->Publish(e);
|
||||
|
||||
Events::Pause p;
|
||||
@@ -864,6 +871,12 @@ bool dd::Systems::LevelSystem::OnStageCleared(const dd::Events::StageCleared &ev
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::LevelSystem::OnArrivedAtNewStage(const dd::Events::ArrivedAtNewStage &event)
|
||||
{
|
||||
m_Cleared = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void dd::Systems::LevelSystem::GetNextLevel()
|
||||
{
|
||||
std::array<int, 42> level;
|
||||
@@ -889,14 +902,14 @@ void dd::Systems::LevelSystem::GetNextLevel()
|
||||
// m is magenta.
|
||||
// d is dark.
|
||||
// Feel free to make your own.
|
||||
glm::vec4 w = glm::vec4(1, 1, 1, 0);
|
||||
glm::vec4 r = glm::vec4(1, 0, 0, 0);
|
||||
glm::vec4 g = glm::vec4(0, 1, 0, 0);
|
||||
glm::vec4 b = glm::vec4(0, 0, 1, 0);
|
||||
glm::vec4 y = glm::vec4(1, 1, 0, 0);
|
||||
glm::vec4 c = glm::vec4(0, 1, 1, 0);
|
||||
glm::vec4 m = glm::vec4(1, 0, 1, 0);
|
||||
glm::vec4 d = glm::vec4(0, 0, 0, 0);
|
||||
glm::vec4 w = glm::vec4(1, 1, 1, 1);
|
||||
glm::vec4 r = glm::vec4(1, 0, 0, 1);
|
||||
glm::vec4 g = glm::vec4(0, 1, 0, 1);
|
||||
glm::vec4 b = glm::vec4(0, 0, 1, 1);
|
||||
glm::vec4 y = glm::vec4(1, 1, 0, 1);
|
||||
glm::vec4 c = glm::vec4(0, 1, 1, 1);
|
||||
glm::vec4 m = glm::vec4(1, 0, 1, 1);
|
||||
glm::vec4 d = glm::vec4(0, 0, 0, 1);
|
||||
|
||||
//glm::vec4 p4 = glm::vec4(asd.f / 255.f, asd.f / 255.f, sad.f / 255.f, 1.f);
|
||||
glm::vec4 br = glm::vec4(143.f / 255.f, 98.f / 255.f, 0.f / 255.f, 1.f);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+41
-14
@@ -30,6 +30,7 @@ void dd::Systems::PadSystem::Initialize()
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EResetBall, &PadSystem::OnResetBall);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EResetAll, &PadSystem::OnResetAll);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ERaiseWater, &PadSystem::OnRaiseWater);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ERaiseWaterWall, &PadSystem::OnRaiseWaterWall);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPause, &PadSystem::OnPause);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EResume, &PadSystem::OnResume);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EKrakenAttack, &PadSystem::OnKrakenAttack);
|
||||
@@ -74,6 +75,17 @@ void dd::Systems::PadSystem::Initialize()
|
||||
|
||||
m_StickTransform = transform;
|
||||
m_StickyAim = sticky;
|
||||
|
||||
/*{
|
||||
auto entChild = m_World->CreateEntity(ent);
|
||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(entChild);
|
||||
transform->Position = glm::vec3(0.f, 12.5f, 0.f);
|
||||
|
||||
transform->Scale = glm::vec3(0.1f, 25.f, 0.1f);
|
||||
std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(entChild);
|
||||
sprite->SpriteFile = "Models/Brick/White.png";
|
||||
sprite->Color = glm::vec4(0.f, 0.5f, 0.f, 0.5f);
|
||||
}*/
|
||||
}
|
||||
|
||||
m_ResetBall = true;
|
||||
@@ -218,8 +230,14 @@ bool dd::Systems::PadSystem::OnKeyDown(const dd::Events::KeyDown &event) {
|
||||
} else if (val == GLFW_KEY_W) {
|
||||
Events::RaiseWater e;
|
||||
e.Amount = 0.2;
|
||||
e.Speed = 0.2;
|
||||
EventBroker->Publish(e);
|
||||
} else if (val == GLFW_KEY_A) {
|
||||
} else if (val == GLFW_KEY_Q) {
|
||||
Events::RaiseWaterWall e;
|
||||
e.Amount = 0.2;
|
||||
e.Speed = 0.2;
|
||||
EventBroker->Publish(e);
|
||||
} else if (val == GLFW_KEY_A) {
|
||||
Events::ResetAll e;
|
||||
EventBroker->Publish(e);
|
||||
} else if (val == GLFW_KEY_M) {
|
||||
@@ -266,6 +284,7 @@ bool dd::Systems::PadSystem::OnKeyDown(const dd::Events::KeyDown &event) {
|
||||
} else if (val == GLFW_KEY_I) {
|
||||
Events::InkBlaster e;
|
||||
e.Shots = 5;
|
||||
e.Speed = 7;
|
||||
EventBroker->Publish(e);
|
||||
} else if (val == GLFW_KEY_K) {
|
||||
Events::KrakenAttack e;
|
||||
@@ -415,21 +434,29 @@ bool dd::Systems::PadSystem::OnResetAll(const dd::Events::ResetAll &event)
|
||||
}
|
||||
|
||||
bool dd::Systems::PadSystem::OnRaiseWater(const dd::Events::RaiseWater &event)
|
||||
{
|
||||
RaisePad(event.Amount, event.Speed);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::PadSystem::OnRaiseWaterWall(const dd::Events::RaiseWaterWall &event)
|
||||
{
|
||||
RaisePad(event.Amount, event.Speed);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::PadSystem::RaisePad(float amount, float speed)
|
||||
{
|
||||
auto transform = Transform();
|
||||
glm::vec3 raise = glm::vec3(0, event.Amount, 0);
|
||||
transform->Position += raise;
|
||||
|
||||
{
|
||||
auto t_waterBody = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(t_waterBody);
|
||||
transform->Position = glm::vec3(0.f, -3.5f, -10.f);
|
||||
transform->Scale = glm::vec3(7.0f, event.Amount * 1.6f, 1.f);
|
||||
auto water = m_World->AddComponent<Components::WaterVolume>(t_waterBody);
|
||||
auto body = m_World->AddComponent<Components::RectangleShape>(t_waterBody);
|
||||
m_World->CommitEntity(t_waterBody);
|
||||
}
|
||||
|
||||
glm::vec3 raise = glm::vec3(0, amount, 0);
|
||||
Events::Move e;
|
||||
e.Entity = m_Entity;
|
||||
e.GoalPosition = transform->Position + raise;
|
||||
e.Speed = speed;
|
||||
e.Queue = true;
|
||||
EventBroker->Publish(e);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -100,6 +100,7 @@ bool dd::Systems::ProjectileSystem::OnInkBlaster(const dd::Events::InkBlaster &e
|
||||
{
|
||||
m_InkBlaster = true;
|
||||
m_Shots = event.Shots;
|
||||
m_InkBlasterSpeed = event.Speed;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -117,9 +118,11 @@ bool dd::Systems::ProjectileSystem::OnActionButton(const dd::Events::ActionButto
|
||||
if (m_InkBlaster && m_SquidLoaded) {
|
||||
auto ent = m_World->CloneEntity(m_InkBlastTemplate);
|
||||
m_World->RemoveComponent<Components::Template>(ent);
|
||||
auto projectile = m_World->GetComponent<Components::Projectile>(ent);
|
||||
projectile->Speed = m_InkBlasterSpeed;
|
||||
auto transform = m_World->GetComponent<Components::Transform>(ent);
|
||||
transform->Position = event.Position;
|
||||
transform->Velocity = glm::vec3(0, 7, 0);
|
||||
transform->Velocity = glm::vec3(0, projectile->Speed, 0);
|
||||
m_Shots--;
|
||||
if (m_Shots <= 0) {
|
||||
auto ball = m_World->GetComponent<Components::Ball>(m_AttachedSquid);
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-10-08.
|
||||
//
|
||||
|
||||
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "Game/ProjectileSystem.h"
|
||||
|
||||
|
||||
void dd::Systems::ProjectileSystem::Initialize()
|
||||
{
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EContact, &ProjectileSystem::OnContact);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPause, &ProjectileSystem::OnPause);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EResume, &ProjectileSystem::OnResume);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EInkBlaster, &ProjectileSystem::OnInkBlaster);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EHitPad, &ProjectileSystem::OnHitPad);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EActionButton, &ProjectileSystem::OnActionButton);
|
||||
|
||||
//Ink Blast
|
||||
{
|
||||
auto ent = m_World->CreateEntity();
|
||||
m_World->SetProperty(ent, "Name", "Projectile");
|
||||
std::shared_ptr<Components::Transform> ctransform = m_World->AddComponent<Components::Transform>(ent);
|
||||
|
||||
auto circleShape = m_World->AddComponent<Components::CircleShape>(ent);
|
||||
auto inkBlastTemplate = m_World->AddComponent<Components::Template>(ent);
|
||||
circleShape->Radius = 0.1f;
|
||||
auto physics = m_World->AddComponent<Components::Physics>(ent);
|
||||
physics->CollisionType = CollisionType::Type::Dynamic;
|
||||
physics->Category = CollisionLayer::Type::Projectile;
|
||||
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Type::Pad | CollisionLayer::Type::Brick | CollisionLayer::Type::Wall);
|
||||
physics->Calculate = true;
|
||||
ctransform->Position = glm::vec3(0.f, 0.f, -10.f);
|
||||
ctransform->Scale = glm::vec3(0.6f, 0.6f, 0.6f);
|
||||
// auto cModel = m_World->AddComponent<Components::Model>(ent);
|
||||
// cModel->ModelFile = "Models/Test/Ball/Sid.obj";
|
||||
auto cSprite = m_World->AddComponent<Components::Sprite>(ent);
|
||||
cSprite->SpriteFile = "Textures/Particles/OilShot.png";
|
||||
auto projectile = m_World->AddComponent<Components::Projectile>(ent);
|
||||
|
||||
m_World->CommitEntity(ent);
|
||||
|
||||
m_InkBlastTemplate = ent;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void dd::Systems::ProjectileSystem::Update(double dt)
|
||||
{
|
||||
if (m_Pause) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void dd::Systems::ProjectileSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
||||
{
|
||||
if (IsPaused()) {
|
||||
return;
|
||||
}
|
||||
auto templateCheck = m_World->GetComponent<Components::Template>(entity);
|
||||
if (templateCheck != nullptr){ return; }
|
||||
|
||||
auto shot = m_World->GetComponent<Components::Projectile>(entity);
|
||||
if (shot != nullptr) {
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
if (transform->Position.y > 8) {
|
||||
m_World->RemoveEntity(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool dd::Systems::ProjectileSystem::OnPause(const dd::Events::Pause &event)
|
||||
{
|
||||
/*if (event.Type != "ProjectileSystem" && event.Type != "All") {
|
||||
return false;
|
||||
}*/
|
||||
|
||||
m_Pause = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::ProjectileSystem::OnResume(const dd::Events::Resume &event)
|
||||
{
|
||||
/*if (event.Type != "ProjectileSystem" && event.Type != "All") {
|
||||
return false;
|
||||
}*/
|
||||
m_Pause = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::ProjectileSystem::OnContact(const dd::Events::Contact &event)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::ProjectileSystem::OnInkBlaster(const dd::Events::InkBlaster &event)
|
||||
{
|
||||
m_InkBlaster = true;
|
||||
m_Shots = event.Shots;
|
||||
m_InkBlasterSpeed = event.Speed;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::ProjectileSystem::OnHitPad(const dd::Events::HitPad &event)
|
||||
{
|
||||
if (m_InkBlaster) {
|
||||
m_SquidLoaded = true;
|
||||
m_AttachedSquid = event.Ball;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::ProjectileSystem::OnActionButton(const dd::Events::ActionButton &event)
|
||||
{
|
||||
if (m_InkBlaster && m_SquidLoaded) {
|
||||
auto ent = m_World->CloneEntity(m_InkBlastTemplate);
|
||||
m_World->RemoveComponent<Components::Template>(ent);
|
||||
auto projectile = m_World->GetComponent<Components::Projectile>(ent);
|
||||
projectile->Speed = m_InkBlasterSpeed;
|
||||
auto transform = m_World->GetComponent<Components::Transform>(ent);
|
||||
transform->Position = event.Position;
|
||||
<<<<<<< HEAD
|
||||
transform->Velocity = glm::vec3(0, projectile->Speed, 0);
|
||||
=======
|
||||
transform->Velocity = glm::vec3(0, 7, 0);
|
||||
>>>>>>> origin/master
|
||||
m_Shots--;
|
||||
if (m_Shots <= 0) {
|
||||
auto ball = m_World->GetComponent<Components::Ball>(m_AttachedSquid);
|
||||
m_InkBlaster = false;
|
||||
m_SquidLoaded = false;
|
||||
ball->InkBlaster = false;
|
||||
ball->Sticky = false;
|
||||
ball->Waiting = true;
|
||||
|
||||
{
|
||||
Events::InkBlasterOver e;
|
||||
e.Ball = m_AttachedSquid;
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
{
|
||||
Events::ActionButton e;
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -97,7 +97,7 @@ bool dd::Systems::TravellingSystem::OnResume(const dd::Events::Resume &event)
|
||||
|
||||
bool dd::Systems::TravellingSystem::OnStageCleared(const dd::Events::StageCleared &event)
|
||||
{
|
||||
if (event.ClearedStage < 5) {
|
||||
if (event.ClearedStage < event.StagesInCluster) {
|
||||
m_Travelling = true;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-10-20.
|
||||
//
|
||||
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "Game/WaterSystem.h"
|
||||
|
||||
void dd::Systems::WaterSystem::Initialize()
|
||||
{
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPause, &WaterSystem::OnPause);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EResume, &WaterSystem::OnResume);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ERelevantObjectCreated, &WaterSystem::OnRelevantObjectCreated);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EStageCleared, &WaterSystem::OnStageCleared);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ERaiseWater, &WaterSystem::OnRaiseWater);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ERaiseWaterWall, &WaterSystem::OnRaiseWaterWall);
|
||||
|
||||
//Water test
|
||||
{
|
||||
auto t_waterBody = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(t_waterBody);
|
||||
transform->Position = glm::vec3(0.f, -3.5f, -10.f);
|
||||
transform->Scale = glm::vec3(7.0f, 1.5f, 1.f);
|
||||
auto water = m_World->AddComponent<Components::WaterVolume>(t_waterBody);
|
||||
auto body = m_World->AddComponent<Components::RectangleShape>(t_waterBody);
|
||||
m_World->CommitEntity(t_waterBody);
|
||||
}
|
||||
}
|
||||
|
||||
void dd::Systems::WaterSystem::Update(double dt)
|
||||
{
|
||||
if (m_Pause) {
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void dd::Systems::WaterSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
||||
{
|
||||
if (m_Pause) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto templateCheck = m_World->GetComponent<Components::Template>(entity);
|
||||
if (templateCheck != nullptr){ return; }
|
||||
|
||||
if (m_BottomWall == 0) {
|
||||
for (auto it = m_World->GetEntities()->begin(); it != m_World->GetEntities()->end(); it++) {
|
||||
if (m_World->GetProperty<std::string>(it->first, "Name") == "BottomWall") {
|
||||
m_BottomWall = entity;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool dd::Systems::WaterSystem::OnPause(const dd::Events::Pause &event)
|
||||
{
|
||||
/*if (event.Type != "WaterSystem" && event.Type != "All") {
|
||||
return false;
|
||||
}*/
|
||||
m_Pause = true;
|
||||
return true;
|
||||
}
|
||||
bool dd::Systems::WaterSystem::OnResume(const dd::Events::Resume &event)
|
||||
{
|
||||
/*if (event.Type != "WaterSystem" && event.Type != "All") {
|
||||
return false;
|
||||
}*/
|
||||
m_Pause = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::WaterSystem::OnRelevantObjectCreated(const dd::Events::RelevantObjectCreated &event)
|
||||
{
|
||||
if (event.ObjectName == "BottomWall") {
|
||||
m_BottomWall = event.ObjectID;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::WaterSystem::OnStageCleared(const dd::Events::StageCleared &event)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::WaterSystem::OnArrivedAtNewStage(const dd::Events::ArrivedAtNewStage &event)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::WaterSystem::OnRaiseWater(const dd::Events::RaiseWater &event)
|
||||
{
|
||||
{
|
||||
auto t_waterBody = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(t_waterBody);
|
||||
transform->Position = glm::vec3(0.f, -3.5f, -10.f);
|
||||
transform->Scale = glm::vec3(7.0f, event.Amount * 1.6f, 1.f);
|
||||
auto water = m_World->AddComponent<Components::WaterVolume>(t_waterBody);
|
||||
auto body = m_World->AddComponent<Components::RectangleShape>(t_waterBody);
|
||||
m_World->CommitEntity(t_waterBody);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::WaterSystem::OnRaiseWaterWall(const dd::Events::RaiseWaterWall &event)
|
||||
{
|
||||
auto transform = m_World->GetComponent<Components::Transform>(m_BottomWall);
|
||||
if (transform != nullptr) {
|
||||
glm::vec3 raise = glm::vec3(0, event.Amount, 0);
|
||||
Events::Move e;
|
||||
e.Entity = m_BottomWall;
|
||||
e.GoalPosition = transform->Position + raise;
|
||||
e.Queue = true;
|
||||
e.Speed = 0.2;
|
||||
EventBroker->Publish(e);
|
||||
} else {
|
||||
LOG_ERROR("There is no BottomWall in WaterSystem");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
Executable → Regular
+3
-7
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "Core/Camera.h"
|
||||
#include "Rendering/Camera.h"
|
||||
|
||||
dd::Camera::Camera(float aspectRatio, float yFOV, float nearClip, float farClip)
|
||||
{
|
||||
@@ -85,12 +85,8 @@ void dd::Camera::UpdateProjectionMatrix()
|
||||
// m_NearClip,
|
||||
// m_FarClip
|
||||
// );
|
||||
m_ProjectionMatrix = glm::perspective(
|
||||
m_FOV,
|
||||
m_AspectRatio,
|
||||
m_NearClip,
|
||||
m_FarClip
|
||||
);
|
||||
|
||||
m_ProjectionMatrix = glm::perspective(m_FOV, m_AspectRatio, m_NearClip, m_FarClip);
|
||||
}
|
||||
|
||||
void dd::Camera::UpdateViewMatrix()
|
||||
@@ -0,0 +1,20 @@
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "Rendering/Model.h"
|
||||
|
||||
dd::Model::Model(std::string fileName)
|
||||
: dd::RawModel(fileName)
|
||||
{
|
||||
D3D11_BUFFER_DESC vbd = { 0 };
|
||||
vbd.ByteWidth = sizeof(RawModel::Vertex) * m_Vertices.size();
|
||||
vbd.BindFlags = D3D11_BIND_VERTEX_BUFFER;
|
||||
D3D11_SUBRESOURCE_DATA vsrd = { m_Vertices.data(), 0, 0 };
|
||||
StaticSystem::Get<Renderer>()->m_Device->CreateBuffer(&vbd, &vsrd, &VertexBuffer);
|
||||
|
||||
D3D11_BUFFER_DESC ibd = { 0 };
|
||||
ibd.ByteWidth = sizeof(unsigned int) * m_Indices.size();
|
||||
ibd.BindFlags = D3D11_BIND_INDEX_BUFFER;
|
||||
D3D11_SUBRESOURCE_DATA idata = { 0 };
|
||||
idata.pSysMem = m_Indices.data();
|
||||
StaticSystem::Get<Renderer>()->m_Device->CreateBuffer(&ibd, &idata, &IndexBuffer);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,429 @@
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "Rendering/Renderer.h"
|
||||
|
||||
#include "Rendering/Model.h"
|
||||
#include "Rendering/Skeleton.h"
|
||||
#include "Rendering/ShaderProgram.h"
|
||||
|
||||
void dd::Renderer::Initialize()
|
||||
{
|
||||
StaticSystem::Set(this);
|
||||
|
||||
// Initialize GLFW
|
||||
if (!glfwInit()) {
|
||||
LOG_ERROR("GLFW: Initialization failed");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// Create a window
|
||||
GLFWmonitor* monitor = nullptr;
|
||||
if (m_Fullscreen) {
|
||||
monitor = glfwGetPrimaryMonitor();
|
||||
}
|
||||
glfwWindowHint(GLFW_SAMPLES, 8);
|
||||
m_Window = glfwCreateWindow(m_Resolution.Width, m_Resolution.Height, "Squidout! (DirectX 11)", monitor, nullptr);
|
||||
if (!m_Window) {
|
||||
LOG_ERROR("GLFW: Failed to create window");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
//glfwMakeContextCurrent(m_Window);
|
||||
|
||||
// Create default camera
|
||||
m_DefaultCamera = std::unique_ptr<dd::Camera>(new dd::Camera((float)m_Resolution.Width / m_Resolution.Height, 45.f, 0.01f, 5000.f));
|
||||
m_DefaultCamera->SetPosition(glm::vec3(0, 0, 0));
|
||||
if (m_Camera == nullptr) {
|
||||
m_Camera = m_DefaultCamera.get();
|
||||
}
|
||||
|
||||
DXGI_SWAP_CHAIN_DESC scd = { 0 };
|
||||
scd.BufferCount = 1;
|
||||
scd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
|
||||
scd.OutputWindow = glfwGetWin32Window(m_Window);
|
||||
scd.SampleDesc.Count = 4;
|
||||
scd.Windowed = TRUE;
|
||||
scd.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
|
||||
|
||||
D3D11CreateDeviceAndSwapChain(
|
||||
NULL,
|
||||
D3D_DRIVER_TYPE_HARDWARE,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
D3D11_SDK_VERSION,
|
||||
&scd,
|
||||
&m_SwapChain,
|
||||
&m_Device,
|
||||
NULL,
|
||||
&m_DeviceContext);
|
||||
|
||||
// Set the back buffer render target
|
||||
ID3D11Texture2D* pBackBuffer;
|
||||
m_SwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (void**)&pBackBuffer);
|
||||
m_Device->CreateRenderTargetView(pBackBuffer, NULL, &m_BackBuffer);
|
||||
pBackBuffer->Release();
|
||||
// Depth buffer
|
||||
D3D11_TEXTURE2D_DESC texd = { };
|
||||
texd.Width = m_Resolution.Width;
|
||||
texd.Height = m_Resolution.Height;
|
||||
texd.ArraySize = 1;
|
||||
texd.MipLevels = 1;
|
||||
texd.SampleDesc.Count = 4;
|
||||
texd.Format = DXGI_FORMAT_D32_FLOAT;
|
||||
texd.BindFlags = D3D11_BIND_DEPTH_STENCIL;
|
||||
ID3D11Texture2D* pDepthBuffer;
|
||||
m_Device->CreateTexture2D(&texd, NULL, &pDepthBuffer);
|
||||
D3D11_DEPTH_STENCIL_VIEW_DESC dsvd = { };
|
||||
dsvd.Format = DXGI_FORMAT_D32_FLOAT;
|
||||
dsvd.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DMS;
|
||||
m_Device->CreateDepthStencilView(pDepthBuffer, &dsvd, &m_DepthBuffer);
|
||||
pDepthBuffer->Release();
|
||||
// Set back and depth buffer
|
||||
m_DeviceContext->OMSetRenderTargets(1, &m_BackBuffer, m_DepthBuffer);
|
||||
|
||||
// Rasterizer settings
|
||||
setDefaultRasterState();
|
||||
|
||||
D3D11_BLEND_DESC blend = { 0 };
|
||||
for (int i = 0; i < 1; i++) {
|
||||
blend.RenderTarget[i].BlendEnable = true;
|
||||
blend.RenderTarget[i].BlendOp = D3D11_BLEND_OP_ADD;
|
||||
blend.RenderTarget[i].SrcBlend = D3D11_BLEND_SRC_ALPHA;
|
||||
blend.RenderTarget[i].DestBlend = D3D11_BLEND_INV_SRC_ALPHA;
|
||||
blend.RenderTarget[i].BlendOpAlpha = D3D11_BLEND_OP_ADD;
|
||||
blend.RenderTarget[i].SrcBlendAlpha = D3D11_BLEND_ONE;
|
||||
blend.RenderTarget[i].DestBlendAlpha = D3D11_BLEND_ZERO;
|
||||
blend.RenderTarget[i].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
|
||||
}
|
||||
ID3D11BlendState* blendState;
|
||||
m_Device->CreateBlendState(&blend, &blendState);
|
||||
m_DeviceContext->OMSetBlendState(blendState, nullptr, 0xffffffff);
|
||||
|
||||
|
||||
D3D11_INPUT_ELEMENT_DESC VertexIED[] = {
|
||||
{"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
||||
{"NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
||||
{"TANGENT", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
||||
{"TANGENT", 1, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
||||
{"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
||||
{"COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
||||
{"COLOR", 1, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
||||
{"BLENDINDICES", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
||||
{"BLENDINDICES", 1, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
||||
{"BLENDWEIGHT", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
||||
{"BLENDWEIGHT", 1, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
||||
};
|
||||
m_ForwardShaderProgram = new ShaderProgram();
|
||||
m_ForwardShaderProgram->CompileVertexShader(L"Shaders/DirectX/vertex.hlsl");
|
||||
m_ForwardShaderProgram->CompilePixelShader(L"Shaders/DirectX/pixel.hlsl");
|
||||
m_ForwardShaderProgram->CreateInputLayout(VertexIED, sizeof(VertexIED) / sizeof(VertexIED[0]));
|
||||
m_GUIShaderProgram = new ShaderProgram();
|
||||
m_GUIShaderProgram->CompileVertexShader(L"Shaders/DirectX/vertex.hlsl");
|
||||
m_GUIShaderProgram->CompilePixelShader(L"Shaders/DirectX/Flat.pixel.hlsl");
|
||||
m_GUIShaderProgram->CreateInputLayout(VertexIED, sizeof(VertexIED) / sizeof(VertexIED[0]));
|
||||
|
||||
// Create constant buffer
|
||||
// TODO: Put this in shader
|
||||
D3D11_BUFFER_DESC bd = { };
|
||||
bd.ByteWidth = sizeof(ConstantBufferStruct);
|
||||
bd.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
|
||||
m_Device->CreateBuffer(&bd, NULL, &constantBuffer);
|
||||
m_DeviceContext->VSSetConstantBuffers(0, 1, &constantBuffer);
|
||||
m_DeviceContext->PSSetConstantBuffers(0, 1, &constantBuffer);
|
||||
|
||||
D3D11_SAMPLER_DESC samplerDesc;
|
||||
samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
|
||||
samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
samplerDesc.MipLODBias = 0.0f;
|
||||
samplerDesc.MaxAnisotropy = 1;
|
||||
samplerDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
|
||||
samplerDesc.BorderColor[0] = 1.f;
|
||||
samplerDesc.BorderColor[1] = 0;
|
||||
samplerDesc.BorderColor[2] = 1.f;
|
||||
samplerDesc.BorderColor[3] = 0;
|
||||
samplerDesc.MinLOD = 0;
|
||||
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
|
||||
m_Device->CreateSamplerState(&samplerDesc, &m_SamplerState);
|
||||
|
||||
m_UnitQuad = ResourceManager::Load<Model>("Models/Core/UnitQuad.obj");
|
||||
m_WhiteSphereTexture = ResourceManager::Load<Texture>("Textures/Test/Water.png");
|
||||
}
|
||||
|
||||
void dd::Renderer::Draw(RenderQueueCollection& rq)
|
||||
{
|
||||
using namespace DirectX::SimpleMath;
|
||||
|
||||
rq.Forward.Jobs.sort(dd::Renderer::DepthSort);
|
||||
|
||||
m_DeviceContext->OMSetRenderTargets(1, &m_BackBuffer, m_DepthBuffer);
|
||||
float color[] = { 0.f, 0.f, 0.f, 1.f };
|
||||
m_DeviceContext->ClearRenderTargetView(m_BackBuffer, color);
|
||||
m_DeviceContext->ClearDepthStencilView(m_DepthBuffer, D3D11_CLEAR_DEPTH, 1.0f, 0);
|
||||
|
||||
// Set the viewport
|
||||
D3D11_VIEWPORT viewport = { 0 };
|
||||
viewport.TopLeftX = 0;
|
||||
viewport.TopLeftY = 0;
|
||||
viewport.Width = m_Resolution.Width;
|
||||
viewport.Height = m_Resolution.Height;
|
||||
viewport.MinDepth = 0;
|
||||
viewport.MaxDepth = 1;
|
||||
m_DeviceContext->RSSetViewports(1, &viewport);
|
||||
|
||||
m_ForwardShaderProgram->Bind();
|
||||
|
||||
Matrix proj = DirectX::SimpleMath::Matrix::CreatePerspectiveFieldOfView(m_Camera->m_FOV, m_Camera->m_AspectRatio, m_Camera->m_NearClip, m_Camera->m_FarClip); // Right-handed
|
||||
Matrix view = Matrix::CreateTranslation(Vector3(m_Camera->Position().x, m_Camera->Position().y, -m_Camera->Position().z));
|
||||
|
||||
int i = 0;
|
||||
constantBufferStruct.NumLights = 0;
|
||||
for (auto &job : rq.Lights) {
|
||||
auto pointLightJob = std::dynamic_pointer_cast<PointLightJob>(job);
|
||||
if (pointLightJob) {
|
||||
glm::vec3 p = pointLightJob->Position;
|
||||
constantBufferStruct.LightPositions[i] = Vector4(p.r, p.g, p.b, 0.f);
|
||||
glm::vec3 c = pointLightJob->DiffuseColor;
|
||||
constantBufferStruct.LightColors[i] = Vector4(c.r, c.g, c.b, 1.f);
|
||||
constantBufferStruct.LightRadii[i] = pointLightJob->Radius;
|
||||
constantBufferStruct.NumLights++;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto &job : rq.Deferred) {
|
||||
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
||||
if (modelJob) {
|
||||
constantBufferStruct.MVP = Matrix(glm::value_ptr(modelJob->ModelMatrix)) * view * proj;
|
||||
constantBufferStruct.InverseTransposeViewModel = (Matrix(glm::value_ptr(modelJob->ModelMatrix)) * view).Transpose().Invert();
|
||||
constantBufferStruct.Color = Vector4(modelJob->Color.r, modelJob->Color.g, modelJob->Color.b, modelJob->Color.a);
|
||||
|
||||
m_DeviceContext->UpdateSubresource(constantBuffer, 0, 0, &constantBufferStruct, 0, 0);
|
||||
m_DeviceContext->PSSetSamplers(0, 1, &m_SamplerState);
|
||||
|
||||
m_DeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
||||
UINT stride = sizeof(Model::Vertex);
|
||||
UINT offset = 0;
|
||||
m_DeviceContext->IASetVertexBuffers(0, 1, &modelJob->Model->VertexBuffer, &stride, &offset);
|
||||
m_DeviceContext->IASetIndexBuffer(modelJob->Model->IndexBuffer, DXGI_FORMAT_R32_UINT, 0);
|
||||
|
||||
if (modelJob->DiffuseTexture != nullptr) {
|
||||
m_DeviceContext->PSSetShaderResources(0, 1, &modelJob->DiffuseTexture->m_ShaderResourceView);
|
||||
}
|
||||
//m_DeviceContext->Draw(modelJob->EndIndex - modelJob->StartIndex + 1, modelJob->StartIndex);
|
||||
m_DeviceContext->DrawIndexed(modelJob->EndIndex - modelJob->StartIndex + 1, modelJob->StartIndex, 0);
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto &job : rq.Forward) {
|
||||
auto spriteJob = std::dynamic_pointer_cast<SpriteJob>(job);
|
||||
if (spriteJob) {
|
||||
constantBufferStruct.MVP = Matrix(glm::value_ptr(spriteJob->ModelMatrix)) * view * proj;
|
||||
constantBufferStruct.InverseTransposeViewModel = (Matrix(glm::value_ptr(spriteJob->ModelMatrix)) * view).Transpose().Invert();
|
||||
constantBufferStruct.Color = Vector4(glm::value_ptr(spriteJob->Color));
|
||||
|
||||
m_DeviceContext->UpdateSubresource(constantBuffer, 0, 0, &constantBufferStruct, 0, 0);
|
||||
m_DeviceContext->PSSetSamplers(0, 1, &m_SamplerState);
|
||||
|
||||
m_DeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
||||
UINT stride = sizeof(Model::Vertex);
|
||||
UINT offset = 0;
|
||||
m_DeviceContext->IASetVertexBuffers(0, 1, &m_UnitQuad->VertexBuffer, &stride, &offset);
|
||||
m_DeviceContext->IASetIndexBuffer(m_UnitQuad->IndexBuffer, DXGI_FORMAT_R32_UINT, 0);
|
||||
|
||||
if (spriteJob->DiffuseTexture != nullptr) {
|
||||
m_DeviceContext->PSSetShaderResources(0, 1, &spriteJob->DiffuseTexture->m_ShaderResourceView);
|
||||
}
|
||||
//m_DeviceContext->Draw(modelJob->EndIndex - modelJob->StartIndex + 1, modelJob->StartIndex);
|
||||
m_DeviceContext->DrawIndexed(m_UnitQuad->m_Indices.size(), 0, 0);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
auto waterJob = std::dynamic_pointer_cast<WaterParticleJob>(job);
|
||||
if (waterJob) {
|
||||
constantBufferStruct.MVP = Matrix(glm::value_ptr(waterJob->ModelMatrix)) * view * proj;
|
||||
constantBufferStruct.InverseTransposeViewModel = (Matrix(glm::value_ptr(waterJob->ModelMatrix)) * view).Transpose().Invert();
|
||||
constantBufferStruct.Color = Vector4(glm::value_ptr(waterJob->Color));
|
||||
|
||||
m_DeviceContext->UpdateSubresource(constantBuffer, 0, 0, &constantBufferStruct, 0, 0);
|
||||
m_DeviceContext->PSSetSamplers(0, 1, &m_SamplerState);
|
||||
|
||||
m_DeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
||||
UINT stride = sizeof(Model::Vertex);
|
||||
UINT offset = 0;
|
||||
m_DeviceContext->IASetVertexBuffers(0, 1, &m_UnitQuad->VertexBuffer, &stride, &offset);
|
||||
m_DeviceContext->IASetIndexBuffer(m_UnitQuad->IndexBuffer, DXGI_FORMAT_R32_UINT, 0);
|
||||
|
||||
m_DeviceContext->PSSetShaderResources(0, 1, &m_WhiteSphereTexture->m_ShaderResourceView);
|
||||
//m_DeviceContext->Draw(modelJob->EndIndex - modelJob->StartIndex + 1, modelJob->StartIndex);
|
||||
m_DeviceContext->DrawIndexed(m_UnitQuad->m_Indices.size(), 0, 0);
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
m_DeviceContext->OMSetRenderTargets(1, &m_BackBuffer, nullptr);
|
||||
m_GUIShaderProgram->Bind();
|
||||
|
||||
for (auto &job : rq.GUI) {
|
||||
auto frameJob = std::dynamic_pointer_cast<FrameJob>(job);
|
||||
if (frameJob) {
|
||||
Rectangle& vp = frameJob->Viewport;
|
||||
glViewport(vp.X, m_Resolution.Height - vp.Y - vp.Height, vp.Width, vp.Height);
|
||||
Rectangle& sc = frameJob->Scissor;
|
||||
if (sc == Rectangle()) {
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
} else {
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
glScissor(sc.X, m_Resolution.Height - sc.Y - sc.Height, sc.Width, sc.Height);
|
||||
}
|
||||
|
||||
D3D11_VIEWPORT viewport = { 0 };
|
||||
viewport.TopLeftX = vp.X;
|
||||
viewport.TopLeftY = vp.Y;
|
||||
viewport.Width = vp.Width;
|
||||
viewport.Height = vp.Height;
|
||||
viewport.MinDepth = 0;
|
||||
viewport.MaxDepth = 1;
|
||||
m_DeviceContext->RSSetViewports(1, &viewport);
|
||||
|
||||
proj = Matrix::Identity;
|
||||
view = Matrix::Identity;
|
||||
Matrix model = Matrix::CreateScale(2.f);
|
||||
constantBufferStruct.MVP = model * view * proj;
|
||||
constantBufferStruct.InverseTransposeViewModel = (model * view).Transpose().Invert();
|
||||
constantBufferStruct.Color = Vector4(glm::value_ptr(frameJob->Color));
|
||||
|
||||
m_DeviceContext->UpdateSubresource(constantBuffer, 0, 0, &constantBufferStruct, 0, 0);
|
||||
m_DeviceContext->PSSetSamplers(0, 1, &m_SamplerState);
|
||||
|
||||
m_DeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
||||
UINT stride = sizeof(Model::Vertex);
|
||||
UINT offset = 0;
|
||||
m_DeviceContext->IASetVertexBuffers(0, 1, &m_UnitQuad->VertexBuffer, &stride, &offset);
|
||||
m_DeviceContext->IASetIndexBuffer(m_UnitQuad->IndexBuffer, DXGI_FORMAT_R32_UINT, 0);
|
||||
|
||||
if (frameJob->DiffuseTexture != nullptr) {
|
||||
m_DeviceContext->PSSetShaderResources(0, 1, &frameJob->DiffuseTexture->m_ShaderResourceView);
|
||||
}
|
||||
//m_DeviceContext->Draw(modelJob->EndIndex - modelJob->StartIndex + 1, modelJob->StartIndex);
|
||||
m_DeviceContext->DrawIndexed(m_UnitQuad->m_Indices.size(), 0, 0);
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
//constantBufferStruct.ModelMatrix = GLMtoDX(glm::mat4(1.f));
|
||||
//constantBufferStruct.ViewMatrix = GLMtoDX(m_Camera->ViewMatrix());
|
||||
//constantBufferStruct.ProjectionMatrix = proj;
|
||||
//constantBufferStruct.InverseTransposeViewModel = GLMtoDX(glm::mat4(1.f));
|
||||
|
||||
m_SwapChain->Present(0, 0);
|
||||
//glfwSwapBuffers(m_Window);
|
||||
}
|
||||
|
||||
//void dd::Renderer::Resize(int width, int height)
|
||||
//{
|
||||
// m_DeviceContext->OMSetRenderTargets(0, 0, 0);
|
||||
// m_BackBuffer->Release();
|
||||
//
|
||||
// HRESULT hr; // TODO: Error handling
|
||||
// // Preserve the existing buffer count and format.
|
||||
// hr = m_SwapChain->ResizeBuffers(0, width, height, DXGI_FORMAT_UNKNOWN, 0);
|
||||
//
|
||||
// ID3D11Texture2D* pBuffer;
|
||||
// hr = m_SwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (void**)&pBuffer);
|
||||
// hr = m_Device->CreateRenderTargetView(pBuffer, NULL, &m_BackBuffer);
|
||||
// pBuffer->Release();
|
||||
// m_DeviceContext->OMSetRenderTargets(1, &BackBuffer, NULL);
|
||||
//
|
||||
// // Set the viewport
|
||||
// D3D11_VIEWPORT viewport = { 0 };
|
||||
// viewport.TopLeftX = 0;
|
||||
// viewport.TopLeftY = 0;
|
||||
// viewport.Width = width;
|
||||
// viewport.Height = height;
|
||||
// m_DeviceContext->RSSetViewports(1, &viewport);
|
||||
//}
|
||||
|
||||
dd::Renderer::~Renderer()
|
||||
{
|
||||
m_SwapChain->Release();
|
||||
m_BackBuffer->Release();
|
||||
m_Device->Release();
|
||||
m_DeviceContext->Release();
|
||||
}
|
||||
|
||||
DirectX::SimpleMath::Matrix dd::Renderer::GLMtoDXModelView(glm::mat4 gm)
|
||||
{
|
||||
gm = glm::transpose(gm);
|
||||
DirectX::SimpleMath::Matrix dm(
|
||||
gm[0][0], gm[0][1], -gm[0][2], gm[0][3],
|
||||
gm[1][0], gm[1][1], -gm[1][2], gm[1][3],
|
||||
-gm[2][0], -gm[2][1], gm[2][2], gm[2][3],
|
||||
gm[3][0], gm[3][1], -gm[3][2], gm[3][3]
|
||||
);
|
||||
return dm;
|
||||
}
|
||||
|
||||
DirectX::SimpleMath::Matrix dd::Renderer::GLMtoDXProjection(glm::mat4 gm)
|
||||
{
|
||||
gm = glm::transpose(gm);
|
||||
DirectX::SimpleMath::Matrix dm(
|
||||
gm[0][0], gm[0][1], gm[0][2], gm[0][3],
|
||||
gm[1][0], gm[1][1], gm[1][2], gm[1][3],
|
||||
-gm[2][0], -gm[2][1], -gm[2][2], -gm[2][3],
|
||||
gm[3][0], gm[3][1], gm[3][2], gm[3][3]
|
||||
);
|
||||
return dm;
|
||||
}
|
||||
|
||||
void dd::Renderer::setDefaultRasterState()
|
||||
{
|
||||
if (m_RasterState != nullptr) {
|
||||
m_RasterState->Release();
|
||||
m_RasterState = nullptr;
|
||||
}
|
||||
|
||||
D3D11_RASTERIZER_DESC rd;
|
||||
memset(&rd, 0, sizeof(D3D11_RASTERIZER_DESC));
|
||||
rd.AntialiasedLineEnable = false;
|
||||
rd.CullMode = D3D11_CULL_BACK;
|
||||
rd.DepthBias = 0;
|
||||
rd.DepthBiasClamp = 0.0f;
|
||||
rd.DepthClipEnable = true;
|
||||
rd.FillMode = D3D11_FILL_SOLID;
|
||||
rd.FrontCounterClockwise = true;
|
||||
rd.MultisampleEnable = false;
|
||||
rd.ScissorEnable = false;
|
||||
rd.SlopeScaledDepthBias = 0.0f;
|
||||
m_Device->CreateRasterizerState(&rd, &m_RasterState);
|
||||
m_DeviceContext->RSSetState(m_RasterState);
|
||||
}
|
||||
|
||||
void dd::Renderer::setGUIRasterState()
|
||||
{
|
||||
if (m_RasterState != nullptr) {
|
||||
m_RasterState->Release();
|
||||
m_RasterState = nullptr;
|
||||
}
|
||||
|
||||
D3D11_RASTERIZER_DESC rd;
|
||||
memset(&rd, 0, sizeof(D3D11_RASTERIZER_DESC));
|
||||
rd.AntialiasedLineEnable = false;
|
||||
rd.CullMode = D3D11_CULL_BACK;
|
||||
rd.DepthBias = 0;
|
||||
rd.DepthBiasClamp = 0.0f;
|
||||
rd.DepthClipEnable = false;
|
||||
rd.FillMode = D3D11_FILL_SOLID;
|
||||
rd.FrontCounterClockwise = true;
|
||||
rd.MultisampleEnable = false;
|
||||
rd.ScissorEnable = false;
|
||||
rd.SlopeScaledDepthBias = 0.0f;
|
||||
m_Device->CreateRasterizerState(&rd, &m_RasterState);
|
||||
m_DeviceContext->RSSetState(m_RasterState);
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "Rendering/ShaderProgram.h"
|
||||
|
||||
dd::ShaderProgram::ShaderProgram()
|
||||
{
|
||||
m_VertexShaderBlob = nullptr;
|
||||
m_VertexShader = nullptr;
|
||||
m_PixelShaderBlob = nullptr;
|
||||
m_PixelShader = nullptr;
|
||||
m_InputLayout = nullptr;
|
||||
}
|
||||
|
||||
dd::ShaderProgram::~ShaderProgram()
|
||||
{
|
||||
if (m_VertexShader != nullptr)
|
||||
m_VertexShader->Release();
|
||||
if (m_VertexShaderBlob != nullptr)
|
||||
m_VertexShaderBlob->Release();
|
||||
if (m_PixelShader != nullptr)
|
||||
m_PixelShader->Release();
|
||||
if (m_PixelShaderBlob != nullptr)
|
||||
m_PixelShaderBlob->Release();
|
||||
if (m_InputLayout != nullptr)
|
||||
m_InputLayout->Release();
|
||||
}
|
||||
|
||||
void dd::ShaderProgram::CompileVertexShader(std::wstring filename)
|
||||
{
|
||||
//D3DX11CompileFromFile(filename.c_str(), 0, 0, "main", "vs_5_0", 0, 0, 0, &m_VertexShaderBlob, 0, 0);
|
||||
ID3DBlob* blob = nullptr;
|
||||
HRESULT result = D3DCompileFromFile(filename.c_str(), nullptr, nullptr, "main", "vs_5_0", 0, 0, &m_VertexShaderBlob, &blob);
|
||||
if (result != S_OK) {
|
||||
std::wstring blobString((wchar_t*)blob->GetBufferPointer(), blob->GetBufferSize());
|
||||
LOG_ERROR("Failed to compile vertex shader!\n\n%s", blobString.c_str());
|
||||
return;
|
||||
}
|
||||
StaticSystem::Get<Renderer>()->m_Device->CreateVertexShader(m_VertexShaderBlob->GetBufferPointer(), m_VertexShaderBlob->GetBufferSize(), NULL, &m_VertexShader);
|
||||
}
|
||||
|
||||
void dd::ShaderProgram::CompilePixelShader(std::wstring filename)
|
||||
{
|
||||
//D3DX11CompileFromFile(filename.c_str(), 0, 0, "main", "ps_5_0", 0, 0, 0, &m_PixelShaderBlob, 0, 0);
|
||||
ID3DBlob* blob = nullptr;
|
||||
HRESULT result = D3DCompileFromFile(filename.c_str(), nullptr, nullptr, "main", "ps_5_0", 0, 0, &m_PixelShaderBlob, &blob);
|
||||
if (result != S_OK) {
|
||||
std::wstring blobString((wchar_t*)blob->GetBufferPointer(), blob->GetBufferSize());
|
||||
LOG_ERROR("Failed to compile pixel shader!\n\n%s", blobString.c_str());
|
||||
return;
|
||||
}
|
||||
StaticSystem::Get<Renderer>()->m_Device->CreatePixelShader(m_PixelShaderBlob->GetBufferPointer(), m_PixelShaderBlob->GetBufferSize(), NULL, &m_PixelShader);
|
||||
}
|
||||
|
||||
void dd::ShaderProgram::Bind()
|
||||
{
|
||||
if (m_VertexShader != nullptr)
|
||||
StaticSystem::Get<Renderer>()->m_DeviceContext->VSSetShader(m_VertexShader, 0, 0);
|
||||
if (m_PixelShader != nullptr)
|
||||
StaticSystem::Get<Renderer>()->m_DeviceContext->PSSetShader(m_PixelShader, 0, 0);
|
||||
if (m_InputLayout != nullptr)
|
||||
StaticSystem::Get<Renderer>()->m_DeviceContext->IASetInputLayout(m_InputLayout);
|
||||
}
|
||||
|
||||
void dd::ShaderProgram::Unbind()
|
||||
{
|
||||
if (m_VertexShader != nullptr) {
|
||||
StaticSystem::Get<Renderer>()->m_DeviceContext->VSSetShader(NULL, 0, 0);
|
||||
}
|
||||
if (m_PixelShader != nullptr) {
|
||||
StaticSystem::Get<Renderer>()->m_DeviceContext->PSSetShader(NULL, 0, 0);
|
||||
}
|
||||
//if (m_InputLayout != nullptr)
|
||||
// dd::RENDERER->DeviceContext->IASetInputLayout(NULL);
|
||||
}
|
||||
|
||||
HRESULT dd::ShaderProgram::CreateInputLayout(D3D11_INPUT_ELEMENT_DESC* ied, UINT numElements)
|
||||
{
|
||||
return StaticSystem::Get<Renderer>()->m_Device->CreateInputLayout(ied, numElements, m_VertexShaderBlob->GetBufferPointer(), m_VertexShaderBlob->GetBufferSize(), &m_InputLayout);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
cbuffer ConstantBuffer
|
||||
{
|
||||
float4x4 MVP;
|
||||
float4x4 ModelMatrix;
|
||||
float4x4 ViewMatrix;
|
||||
float4x4 ProjectionMatrix;
|
||||
float4x4 InverseTransposeViewModel;
|
||||
float4 Color;
|
||||
float4 LightPositions[10];
|
||||
float4 LightColors[10];
|
||||
float LightRadii[10];
|
||||
uint NumLights;
|
||||
}
|
||||
|
||||
Texture2D Texture;
|
||||
SamplerState samplerState;
|
||||
|
||||
struct VOut
|
||||
{
|
||||
float4 PixelPosition : SV_POSITION;
|
||||
float4 Position : POSITION;
|
||||
float4 Normal : NORMAL;
|
||||
float4 Tangent : TANGENT0;
|
||||
float4 BiTangent : TANGENT1;
|
||||
float2 TextureCoord : TEXCOORD;
|
||||
float4 DiffuseColor : COLOR0;
|
||||
float4 SpecularColor : COLOR1;
|
||||
float4 BoneIndices1 : BLENDINDICES0;
|
||||
float4 BoneIndices2 : BLENDINDICES1;
|
||||
float4 BoneWeights1 : BLENDWEIGHT0;
|
||||
float4 BoneWeights2 : BLENDWEIGHT1;
|
||||
};
|
||||
|
||||
float4 main(VOut input) : SV_TARGET
|
||||
{
|
||||
float4 diffuseTexture = Texture.Sample(samplerState, input.TextureCoord) * Color;
|
||||
return diffuseTexture;
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
cbuffer ConstantBuffer
|
||||
{
|
||||
float4x4 MVP;
|
||||
float4x4 ModelMatrix;
|
||||
float4x4 ViewMatrix;
|
||||
float4x4 ProjectionMatrix;
|
||||
float4x4 InverseTransposeViewModel;
|
||||
float4 Color;
|
||||
float4 LightPositions[10];
|
||||
float4 LightColors[10];
|
||||
float LightRadii[10];
|
||||
uint NumLights;
|
||||
}
|
||||
|
||||
Texture2D Texture;
|
||||
SamplerState samplerState;
|
||||
|
||||
struct VOut
|
||||
{
|
||||
float4 PixelPosition : SV_POSITION;
|
||||
float4 Position : POSITION;
|
||||
float4 Normal : NORMAL;
|
||||
float4 Tangent : TANGENT0;
|
||||
float4 BiTangent : TANGENT1;
|
||||
float2 TextureCoord : TEXCOORD;
|
||||
float4 DiffuseColor : COLOR0;
|
||||
float4 SpecularColor : COLOR1;
|
||||
float4 BoneIndices1 : BLENDINDICES0;
|
||||
float4 BoneIndices2 : BLENDINDICES1;
|
||||
float4 BoneWeights1 : BLENDWEIGHT0;
|
||||
float4 BoneWeights2 : BLENDWEIGHT1;
|
||||
};
|
||||
|
||||
float4 phong(float3 lightPos, float lightRadius, float3 lightColor, float3 position, float3 normal, float3 specular, float specularExponent)
|
||||
{
|
||||
float3 LightSpecular = float3(1.0f, 1.0f, 1.0f) * 0.5f;
|
||||
|
||||
// Diffuse
|
||||
lightPos = mul(ViewMatrix, float4(lightPos, 1.0f)).xyz;
|
||||
float3 distanceToLight = lightPos - position;
|
||||
float3 directionToLight = normalize(distanceToLight);
|
||||
float dotProd = dot(directionToLight, normal);
|
||||
float3 Idiffuse = lightColor * dotProd;
|
||||
|
||||
// Specular
|
||||
float3 surfaceToViewer = normalize(-position);
|
||||
float3 halfWay = normalize(surfaceToViewer + directionToLight);
|
||||
float dotSpecular = max(dot(halfWay, normal), 0.0f);
|
||||
float specularFactor = pow(dotSpecular, specularExponent);
|
||||
float3 Ispecular = specular * LightSpecular * specularFactor;
|
||||
|
||||
// Attenuation
|
||||
float dist = distance(lightPos, position);
|
||||
float attenuation = pow(max(0.0f, 1.0f - (dist / lightRadius)), 2.0f);
|
||||
|
||||
return float4((Idiffuse + Ispecular) * attenuation, 1.0f);
|
||||
}
|
||||
|
||||
float4 main(VOut input) : SV_TARGET
|
||||
{
|
||||
//float4 ambientLight = float4(1.0f, 1.0f, 1.0f, 1.0f) * 0.1f;
|
||||
//float4 lightColor = float4(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
//float3 lightToPixel = normalize(LightPosition - mul(input.Position, transpose(ModelMatrix)));
|
||||
//float diffuseBrightness = saturate(dot(lightToPixel, normalize(mul(input.Normal, transpose(ModelMatrix)))));
|
||||
|
||||
float4 diffuseTexture = Texture.Sample(samplerState, input.TextureCoord) * Color;
|
||||
float4 lights = float4(1.f, 1.f, 1.f, 1.f);
|
||||
|
||||
for (uint i = 0; i < NumLights; i++) {
|
||||
float4 light = phong(LightPositions[i], LightRadii[i], LightColors[i].rgb, input.Position, normalize(input.Normal.xyz), float3(1.0f, 1.0f, 1.0f), 1.0f);
|
||||
lights = lights + light;
|
||||
}
|
||||
|
||||
//return float4(1.f, 0.f, 0.f, 1.f);
|
||||
return float4(diffuseTexture.rgb * 0.8f, diffuseTexture.a) * lights;
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
cbuffer ConstantBuffer
|
||||
{
|
||||
float4x4 MVP;
|
||||
float4x4 ModelMatrix;
|
||||
float4x4 ViewMatrix;
|
||||
float4x4 ProjectionMatrix;
|
||||
float4x4 InverseTransposeViewModel;
|
||||
float4 Color;
|
||||
float4 LightPositions[2];
|
||||
}
|
||||
|
||||
struct VIn
|
||||
{
|
||||
float4 Position : POSITION;
|
||||
float4 Normal : NORMAL;
|
||||
float4 Tangent : TANGENT0;
|
||||
float4 BiTangent : TANGENT1;
|
||||
float2 TextureCoord : TEXCOORD;
|
||||
float4 DiffuseColor : COLOR0;
|
||||
float4 SpecularColor : COLOR1;
|
||||
float4 BoneIndices1 : BLENDINDICES0;
|
||||
float4 BoneIndices2 : BLENDINDICES1;
|
||||
float4 BoneWeights1 : BLENDWEIGHT0;
|
||||
float4 BoneWeights2 : BLENDWEIGHT1;
|
||||
};
|
||||
|
||||
struct VOut
|
||||
{
|
||||
float4 PixelPosition : SV_POSITION;
|
||||
float4 Position : POSITION;
|
||||
float4 Normal : NORMAL;
|
||||
float4 Tangent : TANGENT0;
|
||||
float4 BiTangent : TANGENT1;
|
||||
float2 TextureCoord : TEXCOORD;
|
||||
float4 DiffuseColor : COLOR0;
|
||||
float4 SpecularColor : COLOR1;
|
||||
float4 BoneIndices1 : BLENDINDICES0;
|
||||
float4 BoneIndices2 : BLENDINDICES1;
|
||||
float4 BoneWeights1 : BLENDWEIGHT0;
|
||||
float4 BoneWeights2 : BLENDWEIGHT1;
|
||||
};
|
||||
|
||||
VOut main(VIn input)
|
||||
{
|
||||
/*float4 ambientLight = float4(1.0f, 1.0f, 1.0f, 1.0f) * 0.1f;
|
||||
float4 lightPos = float4(0.0f, 0.0f, 8.0f, 0.0f);
|
||||
float4 lightColor = float4(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
float diffuseBrightness = saturate(dot(normal, lightPos));*/
|
||||
|
||||
VOut output;
|
||||
|
||||
output.PixelPosition = mul(MVP, input.Position);
|
||||
//TODO: Make sure that boneTransform works here.
|
||||
output.Position = mul(ModelMatrix * ViewMatrix, float4(input.Position.xyz, 1.0f));
|
||||
output.Normal = mul(InverseTransposeViewModel, float4(input.Normal.xyz, 0.0f));
|
||||
output.Tangent = input.Tangent;
|
||||
output.BiTangent = input.BiTangent;
|
||||
output.TextureCoord = input.TextureCoord;
|
||||
output.DiffuseColor = input.DiffuseColor;
|
||||
output.SpecularColor = input.SpecularColor;
|
||||
output.BoneIndices1 = input.BoneIndices1;
|
||||
output.BoneIndices2 = input.BoneIndices2;
|
||||
output.BoneWeights1 = input.BoneWeights1;
|
||||
output.BoneWeights2 = input.BoneWeights2;
|
||||
|
||||
return output;
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
This file is part of Daydream Engine.
|
||||
Copyright 2014 Adam Byléhn, Tobias Dahl, Simon Holmberg, Viktor Ljung
|
||||
|
||||
Daydream Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Daydream Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Daydream Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "Rendering/Texture.h"
|
||||
|
||||
dd::Texture::Texture(std::string path)
|
||||
{
|
||||
std::unique_ptr<Image> image = std::make_unique<PNG>(path);
|
||||
|
||||
if (image->Width == 0 && image->Height == 0 || image->Format == Image::ImageFormat::Unknown) {
|
||||
image = std::make_unique<PNG>("Textures/Core/ErrorTexture.png");
|
||||
if (image->Width == 0 && image->Height == 0 || image->Format == Image::ImageFormat::Unknown) {
|
||||
LOG_ERROR("Couldn't even load the error texture. This is a dark day indeed.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this->Width = image->Width;
|
||||
this->Height = image->Height;
|
||||
|
||||
D3D11_TEXTURE2D_DESC desc;
|
||||
desc.Width = this->Width;
|
||||
desc.Height = this->Height;
|
||||
desc.MipLevels = 1;
|
||||
desc.ArraySize = 1;
|
||||
desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
desc.SampleDesc.Count = 1;
|
||||
desc.SampleDesc.Quality = 0;
|
||||
desc.Usage = D3D11_USAGE_DEFAULT;
|
||||
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
|
||||
desc.CPUAccessFlags = 0;
|
||||
desc.MiscFlags = 0;
|
||||
|
||||
D3D11_SUBRESOURCE_DATA data;
|
||||
data.pSysMem = image->Data;
|
||||
data.SysMemPitch = image->Width * 4;
|
||||
data.SysMemSlicePitch = image->Width * image->Height * 4;
|
||||
|
||||
HRESULT result;
|
||||
result = StaticSystem::Get<Renderer>()->m_Device->CreateTexture2D(&desc, &data, &m_Texture);
|
||||
if (result != S_OK) {
|
||||
LOG_ERROR("DirectX failed to create texture \"%s\"", path.c_str());
|
||||
}
|
||||
result = StaticSystem::Get<Renderer>()->m_Device->CreateShaderResourceView(m_Texture, nullptr, &m_ShaderResourceView);
|
||||
if (result != S_OK) {
|
||||
LOG_ERROR("DirectX failed to create shader resource view for texture \"%s\"", path.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
dd::Texture::~Texture()
|
||||
{
|
||||
}
|
||||
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "Core/OBJ.h"
|
||||
#include "Rendering/OBJ.h"
|
||||
|
||||
bool dd::OBJ::LoadFromFile(std::string filename)
|
||||
{
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
This file is part of Daydream Engine.
|
||||
Copyright 2014 Adam Byléhn, Tobias Dahl, Simon Holmberg, Viktor Ljung
|
||||
|
||||
Daydream Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Daydream Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Daydream Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "Rendering/Model.h"
|
||||
|
||||
dd::Model::Model(std::string fileName)
|
||||
: RawModel(fileName)
|
||||
{
|
||||
// Generate GL buffers
|
||||
GLuint buffer;
|
||||
glGenBuffers(1, &buffer);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, buffer);
|
||||
glBufferData(GL_ARRAY_BUFFER, m_Vertices.size() * sizeof(Vertex), &m_Vertices[0], GL_STATIC_DRAW);
|
||||
|
||||
glGenBuffers(1, &ElementBuffer);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ElementBuffer);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_Indices.size() * sizeof(unsigned int), &m_Indices[0], GL_STATIC_DRAW);
|
||||
|
||||
glGenVertexArrays(1, &VAO);
|
||||
glBindVertexArray(VAO);
|
||||
GLERROR("GLEW: BufferFail4");
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, buffer);
|
||||
std::vector<int> structSizes = { 3, 3, 3, 3, 2, 4, 4, 4, 4, 4, 4 };
|
||||
int stride = 0;
|
||||
for (int size : structSizes)
|
||||
stride += size;
|
||||
stride *= sizeof(GLfloat);
|
||||
int offset = 0;
|
||||
{
|
||||
int element = 0;
|
||||
glVertexAttribPointer(element, structSizes[element], GL_FLOAT, GL_FALSE, stride, (GLvoid*)(sizeof(GLfloat) * offset)); element++;
|
||||
glVertexAttribPointer(element, structSizes[element], GL_FLOAT, GL_FALSE, stride, (GLvoid*)(sizeof(GLfloat) * (offset += structSizes[element - 1]))); element++;
|
||||
glVertexAttribPointer(element, structSizes[element], GL_FLOAT, GL_FALSE, stride, (GLvoid*)(sizeof(GLfloat) * (offset += structSizes[element - 1]))); element++;
|
||||
glVertexAttribPointer(element, structSizes[element], GL_FLOAT, GL_FALSE, stride, (GLvoid*)(sizeof(GLfloat) * (offset += structSizes[element - 1]))); element++;
|
||||
glVertexAttribPointer(element, structSizes[element], GL_FLOAT, GL_FALSE, stride, (GLvoid*)(sizeof(GLfloat) * (offset += structSizes[element - 1]))); element++;
|
||||
glVertexAttribPointer(element, structSizes[element], GL_FLOAT, GL_FALSE, stride, (GLvoid*)(sizeof(GLfloat) * (offset += structSizes[element - 1]))); element++;
|
||||
glVertexAttribPointer(element, structSizes[element], GL_FLOAT, GL_FALSE, stride, (GLvoid*)(sizeof(GLfloat) * (offset += structSizes[element - 1]))); element++;
|
||||
glVertexAttribPointer(element, structSizes[element], GL_FLOAT, GL_FALSE, stride, (GLvoid*)(sizeof(GLfloat) * (offset += structSizes[element - 1]))); element++;
|
||||
glVertexAttribPointer(element, structSizes[element], GL_FLOAT, GL_FALSE, stride, (GLvoid*)(sizeof(GLfloat) * (offset += structSizes[element - 1]))); element++;
|
||||
glVertexAttribPointer(element, structSizes[element], GL_FLOAT, GL_FALSE, stride, (GLvoid*)(sizeof(GLfloat) * (offset += structSizes[element - 1]))); element++;
|
||||
glVertexAttribPointer(element, structSizes[element], GL_FLOAT, GL_FALSE, stride, (GLvoid*)(sizeof(GLfloat) * (offset += structSizes[element - 1]))); element++;
|
||||
}
|
||||
GLERROR("GLEW: BufferFail5");
|
||||
|
||||
glEnableVertexAttribArray(0);
|
||||
glEnableVertexAttribArray(1);
|
||||
glEnableVertexAttribArray(2);
|
||||
glEnableVertexAttribArray(3);
|
||||
glEnableVertexAttribArray(4);
|
||||
glEnableVertexAttribArray(5);
|
||||
glEnableVertexAttribArray(6);
|
||||
glEnableVertexAttribArray(7);
|
||||
glEnableVertexAttribArray(8);
|
||||
glEnableVertexAttribArray(9);
|
||||
glEnableVertexAttribArray(10);
|
||||
GLERROR("GLEW: BufferFail5");
|
||||
|
||||
//CreateBuffers();
|
||||
}
|
||||
|
||||
dd::Model::~Model()
|
||||
{
|
||||
|
||||
}
|
||||
Executable → Regular
+33
-26
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "Core/Renderer.h"
|
||||
#include "Rendering/Renderer.h"
|
||||
|
||||
void dd::Renderer::Initialize()
|
||||
{
|
||||
@@ -45,7 +45,7 @@ void dd::Renderer::Initialize()
|
||||
glGetIntegerv(GL_MINOR_VERSION, &m_GLVersion[1]);
|
||||
m_GLVendor = (GLchar*)glGetString(GL_VENDOR);
|
||||
std::stringstream ss;
|
||||
ss << m_GLVendor << " OpenGL " << m_GLVersion[0] << "." << m_GLVersion[1];
|
||||
ss << "Squidout! (" << m_GLVendor << " OpenGL " << m_GLVersion[0] << "." << m_GLVersion[1] << ")";
|
||||
#ifdef DEBUG
|
||||
ss << " DEBUG";
|
||||
#endif
|
||||
@@ -80,7 +80,7 @@ void dd::Renderer::LoadShaders()
|
||||
*/
|
||||
|
||||
// Pass #1: Fill G-buffers
|
||||
m_SpDeferred1 = ResourceManager::Load<ShaderProgram>("Shaders/Deferred/1/");
|
||||
m_SpDeferred1 = ResourceManager::Load<ShaderProgram>("Shaders/OpenGL/Deferred/1/");
|
||||
m_SpDeferred1->BindFragDataLocation(0, "GDiffuse");
|
||||
m_SpDeferred1->BindFragDataLocation(1, "GPosition");
|
||||
m_SpDeferred1->BindFragDataLocation(2, "GNormal");
|
||||
@@ -88,30 +88,30 @@ void dd::Renderer::LoadShaders()
|
||||
m_SpDeferred1->Link();
|
||||
|
||||
// Pass #2: Lighting
|
||||
m_SpDeferred2 = ResourceManager::Load<ShaderProgram>("Shaders/Deferred/2/");
|
||||
m_SpDeferred2 = ResourceManager::Load<ShaderProgram>("Shaders/OpenGL/Deferred/2/");
|
||||
//glBindFragDataLocation(m_SPDeferred2, 0, "FragmentLighting");
|
||||
m_SpDeferred2->Link();
|
||||
|
||||
//Water Pass
|
||||
m_SpWater = ResourceManager::Load<ShaderProgram>("Shaders/Deferred/water/");
|
||||
m_SpWater = ResourceManager::Load<ShaderProgram>("Shaders/OpenGL/Deferred/water/");
|
||||
m_SpWater->Link();
|
||||
m_SpWater2 = ResourceManager::Load<ShaderProgram>("Shaders/Deferred/water2/");
|
||||
m_SpWater2 = ResourceManager::Load<ShaderProgram>("Shaders/OpenGL/Deferred/water2/");
|
||||
m_SpWater2->Link();
|
||||
|
||||
// Pass #3: Combining into final image
|
||||
m_SpDeferred3 = ResourceManager::Load<ShaderProgram>("Shaders/Deferred/3/");
|
||||
m_SpDeferred3 = ResourceManager::Load<ShaderProgram>("Shaders/OpenGL/Deferred/3/");
|
||||
m_SpDeferred3->Link();
|
||||
|
||||
/*
|
||||
Forward rendering
|
||||
*/
|
||||
m_SpForward = ResourceManager::Load<ShaderProgram>("Shaders/Forward/");
|
||||
m_SpForward = ResourceManager::Load<ShaderProgram>("Shaders/OpenGL/Forward/");
|
||||
m_SpForward->Link();
|
||||
|
||||
/*
|
||||
Screen draw
|
||||
*/
|
||||
m_SpScreen = ResourceManager::Load<ShaderProgram>("Shaders/Screen/");
|
||||
m_SpScreen = ResourceManager::Load<ShaderProgram>("Shaders/OpenGL/Screen/");
|
||||
m_SpScreen->Link();
|
||||
}
|
||||
|
||||
@@ -121,6 +121,7 @@ void dd::Renderer::CreateBuffers()
|
||||
m_ScreenQuad = CreateQuad();
|
||||
m_UnitQuad = ResourceManager::Load<Model>("Models/Core/UnitQuad.obj");
|
||||
m_UnitSphere = ResourceManager::Load<Model>("Models/Core/UnitSphere.obj");
|
||||
m_ErrorTexture = ResourceManager::Load<Texture>("Textures/Core/ErrorTexture.png");
|
||||
m_StandardNormal = ResourceManager::Load<Texture>("Textures/Core/NeutralNormalMap.png");
|
||||
m_StandardSpecular = ResourceManager::Load<Texture>("Textures/Core/NeutralSpecularMap.png");
|
||||
//m_WhiteSphereTexture = ResourceManager::Load<Texture>("Textures/Test/Water.png");
|
||||
@@ -414,22 +415,28 @@ void dd::Renderer::DrawScene(RenderQueue &objects, ShaderProgram &program)
|
||||
glUniform1f(glGetUniformLocation(shaderProgramHandle, "LightRadius"), 40.0f);
|
||||
glUniform1f(glGetUniformLocation(shaderProgramHandle, "MaterialShininess"), modelJob->Shininess);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, modelJob->DiffuseTexture);
|
||||
if (modelJob->NormalTexture != 0) {
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glBindTexture(GL_TEXTURE_2D, modelJob->NormalTexture);
|
||||
if (modelJob->DiffuseTexture != nullptr) {
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, modelJob->DiffuseTexture->m_Texture);
|
||||
} else {
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glBindTexture(GL_TEXTURE_2D, *m_StandardNormal);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, m_ErrorTexture->m_Texture);
|
||||
}
|
||||
|
||||
if (modelJob->SpecularTexture != 0) {
|
||||
if (modelJob->NormalTexture != nullptr) {
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glBindTexture(GL_TEXTURE_2D, modelJob->NormalTexture->m_Texture);
|
||||
} else {
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glBindTexture(GL_TEXTURE_2D, m_StandardNormal->m_Texture);
|
||||
}
|
||||
|
||||
if (modelJob->SpecularTexture != nullptr) {
|
||||
glActiveTexture(GL_TEXTURE2);
|
||||
glBindTexture(GL_TEXTURE_2D, modelJob->SpecularTexture);
|
||||
glBindTexture(GL_TEXTURE_2D, modelJob->SpecularTexture->m_Texture);
|
||||
} else {
|
||||
glActiveTexture(GL_TEXTURE2);
|
||||
glBindTexture(GL_TEXTURE_2D, *m_StandardSpecular);
|
||||
glBindTexture(GL_TEXTURE_2D, m_StandardSpecular->m_Texture);
|
||||
}
|
||||
|
||||
if (modelJob->Skeleton != nullptr) {
|
||||
@@ -446,8 +453,8 @@ void dd::Renderer::DrawScene(RenderQueue &objects, ShaderProgram &program)
|
||||
}
|
||||
}
|
||||
|
||||
glBindVertexArray(modelJob->VAO);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->ElementBuffer);
|
||||
glBindVertexArray(modelJob->Model->VAO);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
||||
glDrawElementsBaseVertex(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, 0, modelJob->StartIndex);
|
||||
|
||||
continue;
|
||||
@@ -464,11 +471,11 @@ void dd::Renderer::DrawScene(RenderQueue &objects, ShaderProgram &program)
|
||||
glUniform4fv(glGetUniformLocation(shaderProgramHandle, "Color"), 1, glm::value_ptr(spriteJob->Color));
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, spriteJob->DiffuseTexture);
|
||||
glBindTexture(GL_TEXTURE_2D, spriteJob->DiffuseTexture->m_Texture);
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glBindTexture(GL_TEXTURE_2D, spriteJob->NormalTexture);
|
||||
glBindTexture(GL_TEXTURE_2D, spriteJob->NormalTexture->m_Texture);
|
||||
glActiveTexture(GL_TEXTURE2);
|
||||
glBindTexture(GL_TEXTURE_2D, spriteJob->SpecularTexture);
|
||||
glBindTexture(GL_TEXTURE_2D, spriteJob->SpecularTexture->m_Texture);
|
||||
|
||||
glBindVertexArray(m_UnitQuad->VAO);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_UnitQuad->ElementBuffer);
|
||||
@@ -536,7 +543,7 @@ void dd::Renderer::DrawWater(RenderQueue &rq)
|
||||
glm::value_ptr(viewMatrix));
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, *m_WhiteSphereTexture);
|
||||
glBindTexture(GL_TEXTURE_2D, m_WhiteSphereTexture->m_Texture);
|
||||
|
||||
glBindVertexArray(m_UnitQuad->VAO);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_UnitQuad->ElementBuffer);
|
||||
@@ -691,7 +698,7 @@ void dd::Renderer::DrawGUI(dd::RenderQueue& rq)
|
||||
glUniform4fv(glGetUniformLocation(*m_SpScreen, "Color"), 1, glm::value_ptr(frameJob->Color));
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, frameJob->DiffuseTexture);
|
||||
glBindTexture(GL_TEXTURE_2D, frameJob->DiffuseTexture->m_Texture);
|
||||
//glActiveTexture(GL_TEXTURE1);
|
||||
//glBindTexture(GL_TEXTURE_2D, frameJob->NormalTexture);
|
||||
//glActiveTexture(GL_TEXTURE2);
|
||||
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "Core/ShaderProgram.h"
|
||||
#include "Rendering/ShaderProgram.h"
|
||||
|
||||
void dd::Shader::Compile()
|
||||
{
|
||||
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
+1
-1
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "Core/Texture.h"
|
||||
#include "Rendering/Texture.h"
|
||||
|
||||
dd::Texture::Texture(std::string path)
|
||||
{
|
||||
Executable → Regular
+9
-4
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "Core/PNG.h"
|
||||
#include "Rendering/PNG.h"
|
||||
|
||||
dd::PNG::PNG(std::string path)
|
||||
{
|
||||
@@ -75,8 +75,6 @@ dd::PNG::PNG(std::string path)
|
||||
}
|
||||
switch (color_type) {
|
||||
case PNG_COLOR_TYPE_RGB:
|
||||
Format = Image::ImageFormat::RGB;
|
||||
break;
|
||||
case PNG_COLOR_TYPE_RGBA:
|
||||
Format = Image::ImageFormat::RGBA;
|
||||
break;
|
||||
@@ -84,8 +82,15 @@ dd::PNG::PNG(std::string path)
|
||||
LOG_ERROR("libpng: Unsupported color format \"%i\" of image \"%s\"", color_type, path.c_str());
|
||||
return;
|
||||
}
|
||||
unsigned int row_bytes = png_get_rowbytes(png_ptr, info_ptr);
|
||||
|
||||
// Convert RGB to RGBA, since DirectX rather treat them all the same way
|
||||
if (color_type == PNG_COLOR_TYPE_RGB) {
|
||||
LOG_DEBUG("Converting RGB to RGBA for \"%s\"", path.c_str());
|
||||
png_set_add_alpha(png_ptr, 0xff, PNG_FILLER_AFTER);
|
||||
png_read_update_info(png_ptr, info_ptr);
|
||||
}
|
||||
|
||||
unsigned int row_bytes = png_get_rowbytes(png_ptr, info_ptr);
|
||||
this->Data = new unsigned char[height * row_bytes];
|
||||
png_bytep* row_pointers = new png_bytep[height];
|
||||
|
||||
Executable → Regular
+5
-57
@@ -17,9 +17,9 @@
|
||||
*/
|
||||
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "Core/Model.h"
|
||||
#include "Rendering/RawModel.h"
|
||||
|
||||
dd::Model::Model(std::string fileName)
|
||||
dd::RawModel::RawModel(std::string fileName)
|
||||
{
|
||||
Assimp::Importer importer;
|
||||
const aiScene* scene = importer.ReadFile(fileName, aiProcess_CalcTangentSpace | aiProcess_Triangulate);
|
||||
@@ -29,7 +29,7 @@ dd::Model::Model(std::string fileName)
|
||||
LOG_ERROR("Assimp error: %s", importer.GetErrorString());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
auto m = scene->mRootNode->mTransformation;
|
||||
m_Matrix = glm::mat4(
|
||||
m.a1, m.a2, m.a3, m.a4,
|
||||
@@ -303,68 +303,16 @@ dd::Model::Model(std::string fileName)
|
||||
|
||||
m_Skeleton->Animations[animationName] = skelAnim;
|
||||
}
|
||||
|
||||
// Generate GL buffers
|
||||
GLuint buffer;
|
||||
glGenBuffers(1, &buffer);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, buffer);
|
||||
glBufferData(GL_ARRAY_BUFFER, m_Vertices.size() * sizeof(Vertex), &m_Vertices[0], GL_STATIC_DRAW);
|
||||
|
||||
glGenBuffers(1, &ElementBuffer);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ElementBuffer);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_Indices.size() * sizeof(unsigned int), &m_Indices[0], GL_STATIC_DRAW);
|
||||
|
||||
glGenVertexArrays(1, &VAO);
|
||||
glBindVertexArray(VAO);
|
||||
GLERROR("GLEW: BufferFail4");
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, buffer);
|
||||
std::vector<int> structSizes = { 3, 3, 3, 3, 2, 4, 4, 4, 4, 4, 4 };
|
||||
int stride = 0;
|
||||
for (int size : structSizes)
|
||||
stride += size;
|
||||
stride *= sizeof(GLfloat);
|
||||
int offset = 0;
|
||||
{
|
||||
int element = 0;
|
||||
glVertexAttribPointer(element, structSizes[element], GL_FLOAT, GL_FALSE, stride, (GLvoid*)(sizeof(GLfloat) * offset)); element++;
|
||||
glVertexAttribPointer(element, structSizes[element], GL_FLOAT, GL_FALSE, stride, (GLvoid*)(sizeof(GLfloat) * (offset += structSizes[element - 1]))); element++;
|
||||
glVertexAttribPointer(element, structSizes[element], GL_FLOAT, GL_FALSE, stride, (GLvoid*)(sizeof(GLfloat) * (offset += structSizes[element - 1]))); element++;
|
||||
glVertexAttribPointer(element, structSizes[element], GL_FLOAT, GL_FALSE, stride, (GLvoid*)(sizeof(GLfloat) * (offset += structSizes[element - 1]))); element++;
|
||||
glVertexAttribPointer(element, structSizes[element], GL_FLOAT, GL_FALSE, stride, (GLvoid*)(sizeof(GLfloat) * (offset += structSizes[element - 1]))); element++;
|
||||
glVertexAttribPointer(element, structSizes[element], GL_FLOAT, GL_FALSE, stride, (GLvoid*)(sizeof(GLfloat) * (offset += structSizes[element - 1]))); element++;
|
||||
glVertexAttribPointer(element, structSizes[element], GL_FLOAT, GL_FALSE, stride, (GLvoid*)(sizeof(GLfloat) * (offset += structSizes[element - 1]))); element++;
|
||||
glVertexAttribPointer(element, structSizes[element], GL_FLOAT, GL_FALSE, stride, (GLvoid*)(sizeof(GLfloat) * (offset += structSizes[element - 1]))); element++;
|
||||
glVertexAttribPointer(element, structSizes[element], GL_FLOAT, GL_FALSE, stride, (GLvoid*)(sizeof(GLfloat) * (offset += structSizes[element - 1]))); element++;
|
||||
glVertexAttribPointer(element, structSizes[element], GL_FLOAT, GL_FALSE, stride, (GLvoid*)(sizeof(GLfloat) * (offset += structSizes[element - 1]))); element++;
|
||||
glVertexAttribPointer(element, structSizes[element], GL_FLOAT, GL_FALSE, stride, (GLvoid*)(sizeof(GLfloat) * (offset += structSizes[element - 1]))); element++;
|
||||
}
|
||||
GLERROR("GLEW: BufferFail5");
|
||||
|
||||
glEnableVertexAttribArray(0);
|
||||
glEnableVertexAttribArray(1);
|
||||
glEnableVertexAttribArray(2);
|
||||
glEnableVertexAttribArray(3);
|
||||
glEnableVertexAttribArray(4);
|
||||
glEnableVertexAttribArray(5);
|
||||
glEnableVertexAttribArray(6);
|
||||
glEnableVertexAttribArray(7);
|
||||
glEnableVertexAttribArray(8);
|
||||
glEnableVertexAttribArray(9);
|
||||
glEnableVertexAttribArray(10);
|
||||
GLERROR("GLEW: BufferFail5");
|
||||
|
||||
//CreateBuffers();
|
||||
}
|
||||
|
||||
dd::Model::~Model()
|
||||
dd::RawModel::~RawModel()
|
||||
{
|
||||
if (m_Skeleton) {
|
||||
delete m_Skeleton;
|
||||
}
|
||||
}
|
||||
|
||||
void dd::Model::CreateSkeleton(std::vector<std::tuple<std::string, glm::mat4>> &boneInfo, std::map<std::string, int> &boneNameMapping, aiNode* node, int parentID)
|
||||
void dd::RawModel::CreateSkeleton(std::vector<std::tuple<std::string, glm::mat4>> &boneInfo, std::map<std::string, int> &boneNameMapping, aiNode* node, int parentID)
|
||||
{
|
||||
std::string nodeName = node->mName.C_Str();
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "Core/Skeleton.h"
|
||||
#include "Rendering/Skeleton.h"
|
||||
|
||||
int dd::Skeleton::CreateBone(int ID, int parentID, std::string name, glm::mat4 offsetMatrix)
|
||||
{
|
||||
Reference in New Issue
Block a user