Skip to content
This repository was archived by the owner on Jun 11, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/engine/scene/Entity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@
#include "engine/render/BoundingSphere.hpp"
#include "engine/render/Model.hpp"
#include "engine/render/RenderPipelineManager.hpp"
#include "engine/scene/Material.hpp"

namespace engine::scene {

class Entity {
private:
std::shared_ptr<render::Model> model;
render::BoundingSphere boundingSphere;
std::string texturePath;
Material material;

public:
Entity(const tinyxml2::XMLElement *modelElement,
Expand Down
35 changes: 35 additions & 0 deletions include/engine/scene/Material.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/// Copyright 2025 Ana Oliveira, Humberto Gomes, Mariana Rocha, Sara Lopes
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.

#pragma once

#include <glm/mat4x4.hpp>
#include <tinyxml2.h>

namespace engine::scene {

class Material {
protected:
glm::vec3 diffuse;
glm::vec3 ambient;
glm::vec3 specular;
glm::vec3 emissive;
float shininess;

public:
Material();
explicit Material(const tinyxml2::XMLElement *colorElement);
};

}
2 changes: 2 additions & 0 deletions include/engine/scene/Scene.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "engine/render/RenderPipelineManager.hpp"
#include "engine/scene/camera/Camera.hpp"
#include "engine/scene/Group.hpp"
#include "engine/scene/light/Light.hpp"

namespace engine::scene {

Expand All @@ -31,6 +32,7 @@ class Scene {
std::unique_ptr<camera::Camera> camera;
std::vector<std::unique_ptr<Group>> groups;
render::Axis xAxis, yAxis, zAxis;
std::vector<std::unique_ptr<light::Light>> lights;

public:
explicit Scene(const std::string &file);
Expand Down
29 changes: 29 additions & 0 deletions include/engine/scene/light/DirectionalLight.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/// Copyright 2025 Ana Oliveira, Humberto Gomes, Mariana Rocha, Sara Lopes
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.

#pragma once

#include "Light.hpp"

namespace engine::scene::light {

class DirectionalLight : public Light {
private:
glm::vec3 direction;

public:
explicit DirectionalLight(const glm::vec3 &_direction);
};

}
30 changes: 30 additions & 0 deletions include/engine/scene/light/Light.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/// Copyright 2025 Ana Oliveira, Humberto Gomes, Mariana Rocha, Sara Lopes
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.

#pragma once

#include <glm/vec3.hpp>

namespace engine::scene::light {

class Light {
protected:
glm::vec3 color;

public:
Light();
virtual ~Light() = default;
};

}
28 changes: 28 additions & 0 deletions include/engine/scene/light/LightFactory.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/// Copyright 2025 Ana Oliveira, Humberto Gomes, Mariana Rocha, Sara Lopes
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.

#pragma once

#include <tinyxml2.h>

#include "engine/scene/light/Light.hpp"

namespace engine::scene::light {

class LightFactory {
public:
static std::unique_ptr<Light> createFromXML(const tinyxml2::XMLElement *lightElement);
};

}
29 changes: 29 additions & 0 deletions include/engine/scene/light/PointLight.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/// Copyright 2025 Ana Oliveira, Humberto Gomes, Mariana Rocha, Sara Lopes
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.

#pragma once

#include "Light.hpp"

namespace engine::scene::light {

class PointLight : public Light {
private:
glm::vec3 position;

public:
explicit PointLight(const glm::vec3 &_position);
};

}
31 changes: 31 additions & 0 deletions include/engine/scene/light/Spotlight.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/// Copyright 2025 Ana Oliveira, Humberto Gomes, Mariana Rocha, Sara Lopes
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.

#pragma once

#include "Light.hpp"

namespace engine::scene::light {

class Spotlight : public Light {
private:
glm::vec3 position;
glm::vec3 direction;
float cutoff;

public:
explicit Spotlight(const glm::vec3 &_position, const glm::vec3 &_direction, float _cutoff);
};

}
3 changes: 3 additions & 0 deletions include/utils/XMLUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ class XMLUtils {
static const tinyxml2::XMLElement *getSingleChild(const tinyxml2::XMLNode *parent,
const std::string &name);
static glm::vec3 getXYZ(const tinyxml2::XMLElement *element);
static glm::vec3 getRGB(const tinyxml2::XMLElement *element);
static glm::vec3 getLightDirection(const tinyxml2::XMLElement *element);
static glm::vec3 getLightPosition(const tinyxml2::XMLElement *element);
};

}
Binary file added professorTests/scenes/test_files_phase_4/4_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added professorTests/scenes/test_files_phase_4/4_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added professorTests/scenes/test_files_phase_4/4_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added professorTests/scenes/test_files_phase_4/4_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added professorTests/scenes/test_files_phase_4/4_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added professorTests/scenes/test_files_phase_4/4_6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added professorTests/scenes/test_files_phase_4/4_7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added professorTests/scenes/test_files_phase_4/box.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added professorTests/scenes/test_files_phase_4/cone.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions professorTests/scenes/test_files_phase_4/notes for phase IV.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Notes on phase IV:

- the light direction is assumed to be the direction towards the light.
- For lighting to work properly when scales are applied to models, the following code should be added to the initialization:

glEnable(GL_RESCALE_NORMAL);

Activating this feature will result in normalized normals after applying the geometric transformations, and before applying lighting. This is relevant when using scales-

- To allow for ambient colors to be reproduced without having to activate the ambient component for all lights, the following code should be added to the initialization:

float amb[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, amb);

- Regarding texture mapping as provided in the screen shots, groups may offer different mappings for the cone and box, in which case the group should build a project XML file to illustrate their mapping.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions professorTests/scenes/test_files_phase_4/test_4_1.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<world>
<window width="512" height="512" />
<camera>
<position x="1.757135" y="1.799201" z="3.416921" />
<lookAt x="0" y="0" z="0" />
<up x="0" y="1" z="0" />
<projection fov="60" near="1" far="1000" />
</camera>

<lights>
<light type="directional" dirX="1" dirY="0.7" dirZ="0.5"/>
</lights>
<group>
<models>
<model file="../../models/box_2_3.3d" > <!-- generator box 2 3 box_2_3.3d -->
<color>
<diffuse R="200" G="200" B="000" />
<ambient R="50" G="50" B="00" />
<specular R="0" G="0" B="0" />
<emissive R="0" G="0" B="0" />
<shininess value="0" />
</color>
</model>
</models>
</group>
</world>
26 changes: 26 additions & 0 deletions professorTests/scenes/test_files_phase_4/test_4_2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<world>
<window width="512" height="512" />
<camera>
<position x="1.757135" y="1.799201" z="3.416921" />
<lookAt x="0" y="0" z="0" />
<up x="0" y="1" z="0" />
<projection fov="60" near="1" far="1000" />
</camera>

<lights>
<light type="directional" dirX="1" dirY="0.7" dirZ="0.5"/>
</lights>
<group>
<models>
<model file="../../models/box_2_3.3d" > <!-- generator box 2 3 box_2_3.3d -->
<color>
<diffuse R="200" G="200" B="000" />
<ambient R="50" G="50" B="00" />
<specular R="0" G="0" B="0" />
<emissive R="255" G="0" B="0" />
<shininess value="0" />
</color>
</model>
</models>
</group>
</world>
Loading