Documenting done.
This commit is contained in:
@ -15,13 +15,36 @@ namespace Dawn {
|
||||
public:
|
||||
SceneItem &item;
|
||||
|
||||
/**
|
||||
* Constructs a new SceneItemComponent. Components are attached to
|
||||
* SceneItems and will be individual responsibility components, and must
|
||||
* communicate to other items/components using methods and events.
|
||||
*
|
||||
* @param item Scene Item thsi component belongs to.
|
||||
*/
|
||||
SceneItemComponent(SceneItem &item);
|
||||
|
||||
/**
|
||||
* Requested on the first frame that the parent scene item has become
|
||||
* active.
|
||||
*/
|
||||
virtual void start() = 0;
|
||||
|
||||
/**
|
||||
* Shorthand to return the scene that this component's item belongs to.
|
||||
* @return The current scene.
|
||||
*/
|
||||
Scene & getScene();
|
||||
|
||||
/**
|
||||
* Shorthand to return the game that this scene belongs to.
|
||||
* @return The current game.
|
||||
*/
|
||||
DawnGame & getGame();
|
||||
|
||||
/**
|
||||
* Cleanup the SceneItemComponent.
|
||||
*/
|
||||
virtual ~SceneItemComponent();
|
||||
};
|
||||
}
|
@ -3,11 +3,5 @@
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
# Sources
|
||||
target_sources(${DAWN_TARGET_NAME}
|
||||
PRIVATE
|
||||
DummyComponent.cpp
|
||||
)
|
||||
|
||||
# Subdirs
|
||||
add_subdirectory(display)
|
@ -4,7 +4,6 @@
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "scene/components/DummyComponent.hpp"
|
||||
#include "scene/components/display/Camera.hpp"
|
||||
#include "scene/components/display/MeshRenderer.hpp"
|
||||
#include "scene/components/display/Material.hpp"
|
@ -1,12 +0,0 @@
|
||||
// Copyright (c) 2022 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#include "DummyComponent.hpp"
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
void DummyComponent::start() {
|
||||
std::cout << "Dummy Component Start" << std::endl;
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
// Copyright (c) 2022 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "scene/SceneItemComponent.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class DummyComponent : public SceneItemComponent {
|
||||
public:
|
||||
DummyComponent(SceneItem &item) :
|
||||
SceneItemComponent(item)
|
||||
{
|
||||
std::cout << "Dummy Component Initialized" << std::endl;
|
||||
};
|
||||
|
||||
void start() override;
|
||||
};
|
||||
}
|
@ -45,7 +45,6 @@ namespace Dawn {
|
||||
void updateProjection();
|
||||
|
||||
void lookAt(glm::vec3 position, glm::vec3 look);
|
||||
|
||||
void lookAt(glm::vec3 position, glm::vec3 look, glm::vec3 up);
|
||||
|
||||
/**
|
||||
|
@ -17,7 +17,6 @@ Material::Material(SceneItem &item) :
|
||||
}
|
||||
|
||||
void Material::updateShaderParameters() {
|
||||
std::cout << "Updating params" << std::endl;
|
||||
this->colorValues.clear();
|
||||
this->boolValues.clear();
|
||||
|
||||
|
@ -11,29 +11,56 @@ namespace Dawn {
|
||||
class Shader;
|
||||
|
||||
class Material : public SceneItemComponent {
|
||||
friend class RenderPipeline;
|
||||
|
||||
private:
|
||||
std::shared_ptr<Shader> shader;
|
||||
|
||||
/**
|
||||
* Internal method that will be invoked to go through and update all of
|
||||
* the shader parameters whenever the shader is swapped out.
|
||||
*/
|
||||
void updateShaderParameters();
|
||||
|
||||
|
||||
public:
|
||||
std::map<shaderparameter_t, enum ShaderParameterType> parameters;
|
||||
|
||||
std::map<shaderparameter_t, struct Color> colorValues;
|
||||
std::map<shaderparameter_t, bool_t> boolValues;
|
||||
std::map<shaderparameter_t, glm::mat4> matrixValues;
|
||||
std::map<shaderparameter_t, glm::vec3> vec3Values;
|
||||
|
||||
/**
|
||||
* Material component constructor.
|
||||
*
|
||||
* @param item Scene Item this component belongs to.
|
||||
*/
|
||||
Material(SceneItem &item);
|
||||
|
||||
/**
|
||||
* Return the shader this material is currently using.
|
||||
*
|
||||
* @return Shader pointer to the currently bound shader.
|
||||
*/
|
||||
std::shared_ptr<Shader> getShader();
|
||||
|
||||
/**
|
||||
* Sets the shader for the material to use. This will also clear and
|
||||
* update all of the parameters from the shaders' default parameter list.
|
||||
*
|
||||
* @param shader Shader to set.
|
||||
*/
|
||||
void setShader(std::shared_ptr<Shader> shader);
|
||||
|
||||
/**
|
||||
* Protected method that can be called, likely by the render pipeline, to
|
||||
* set and update all of the shader parameters from this material on to
|
||||
* the shader.
|
||||
*
|
||||
* This method assumes that the shader has already been bound.
|
||||
*/
|
||||
void setShaderParameters();
|
||||
|
||||
/**
|
||||
* Overrides the default SceneItemComponent start method.
|
||||
*/
|
||||
void start() override;
|
||||
};
|
||||
}
|
@ -12,8 +12,16 @@ namespace Dawn {
|
||||
public:
|
||||
std::shared_ptr<Mesh> mesh = nullptr;
|
||||
|
||||
/**
|
||||
* Constructs a MeshRenderer scene item component.
|
||||
*
|
||||
* @param item Scene Item this mesh renderer belongs to.
|
||||
*/
|
||||
MeshRenderer(SceneItem &item);
|
||||
|
||||
/**
|
||||
* Overrides the default SceneItemComponent start method.
|
||||
*/
|
||||
void start() override;
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user