Scene context improving but not finished.
This commit is contained in:
@@ -21,65 +21,65 @@ void Camera::onDispose() {
|
||||
renderTarget = nullptr;
|
||||
}
|
||||
|
||||
void Camera::load(SceneComponentLoadContext &ctx) {
|
||||
void Camera::load(std::shared_ptr<SceneLoadContext> ctx) {
|
||||
SceneComponent::load(ctx);
|
||||
|
||||
if(ctx.data.contains("fov")) {
|
||||
this->fov = Math::deg2rad(ctx.data["fov"].get<float_t>());
|
||||
if(ctx->data.contains("fov")) {
|
||||
this->fov = Math::deg2rad(ctx->data["fov"].get<float_t>());
|
||||
}
|
||||
|
||||
if(ctx.data.contains("cameraType")) {
|
||||
if(ctx->data.contains("cameraType")) {
|
||||
if(
|
||||
ctx.data["cameraType"] == "orthogonal" ||
|
||||
ctx.data["cameraType"] == "orthographic" ||
|
||||
ctx.data["cameraType"] == "ortho"
|
||||
ctx->data["cameraType"] == "orthogonal" ||
|
||||
ctx->data["cameraType"] == "orthographic" ||
|
||||
ctx->data["cameraType"] == "ortho"
|
||||
) {
|
||||
this->type = CameraType::ORTHOGONAL;
|
||||
} else if(ctx.data["cameraType"] == "perspective") {
|
||||
} else if(ctx->data["cameraType"] == "perspective") {
|
||||
this->type = CameraType::PERSPECTIVE;
|
||||
} else {
|
||||
assertUnreachable("Invalid Camera Type!");
|
||||
}
|
||||
}
|
||||
|
||||
if(ctx.data.contains("orthoLeft")) {
|
||||
this->orthoLeft = ctx.data["orthoLeft"].get<float_t>();
|
||||
} else if(ctx.data.contains("left")) {
|
||||
this->orthoLeft = ctx.data["left"].get<float_t>();
|
||||
if(ctx->data.contains("orthoLeft")) {
|
||||
this->orthoLeft = ctx->data["orthoLeft"].get<float_t>();
|
||||
} else if(ctx->data.contains("left")) {
|
||||
this->orthoLeft = ctx->data["left"].get<float_t>();
|
||||
}
|
||||
|
||||
if(ctx.data.contains("orthoRight")) {
|
||||
this->orthoRight = ctx.data["orthoRight"].get<float_t>();
|
||||
} else if(ctx.data.contains("right")) {
|
||||
this->orthoRight = ctx.data["right"].get<float_t>();
|
||||
if(ctx->data.contains("orthoRight")) {
|
||||
this->orthoRight = ctx->data["orthoRight"].get<float_t>();
|
||||
} else if(ctx->data.contains("right")) {
|
||||
this->orthoRight = ctx->data["right"].get<float_t>();
|
||||
}
|
||||
|
||||
if(ctx.data.contains("orthoBottom")) {
|
||||
this->orthoBottom = ctx.data["orthoBottom"].get<float_t>();
|
||||
} else if(ctx.data.contains("bottom")) {
|
||||
this->orthoBottom = ctx.data["bottom"].get<float_t>();
|
||||
if(ctx->data.contains("orthoBottom")) {
|
||||
this->orthoBottom = ctx->data["orthoBottom"].get<float_t>();
|
||||
} else if(ctx->data.contains("bottom")) {
|
||||
this->orthoBottom = ctx->data["bottom"].get<float_t>();
|
||||
}
|
||||
|
||||
if(ctx.data.contains("orthoTop")) {
|
||||
this->orthoTop = ctx.data["orthoTop"].get<float_t>();
|
||||
} else if(ctx.data.contains("top")) {
|
||||
this->orthoTop = ctx.data["top"].get<float_t>();
|
||||
if(ctx->data.contains("orthoTop")) {
|
||||
this->orthoTop = ctx->data["orthoTop"].get<float_t>();
|
||||
} else if(ctx->data.contains("top")) {
|
||||
this->orthoTop = ctx->data["top"].get<float_t>();
|
||||
}
|
||||
|
||||
if(ctx.data.contains("clipNear")) {
|
||||
this->clipNear = ctx.data["clipNear"].get<float_t>();
|
||||
} else if(ctx.data.contains("near")) {
|
||||
this->clipNear = ctx.data["near"].get<float_t>();
|
||||
} else if(ctx.data.contains("zNear")) {
|
||||
this->clipNear = ctx.data["zNear"].get<float_t>();
|
||||
if(ctx->data.contains("clipNear")) {
|
||||
this->clipNear = ctx->data["clipNear"].get<float_t>();
|
||||
} else if(ctx->data.contains("near")) {
|
||||
this->clipNear = ctx->data["near"].get<float_t>();
|
||||
} else if(ctx->data.contains("zNear")) {
|
||||
this->clipNear = ctx->data["zNear"].get<float_t>();
|
||||
}
|
||||
|
||||
if(ctx.data.contains("clipFar")) {
|
||||
this->clipFar = ctx.data["clipFar"].get<float_t>();
|
||||
} else if(ctx.data.contains("far")) {
|
||||
this->clipFar = ctx.data["far"].get<float_t>();
|
||||
} else if(ctx.data.contains("zFar")) {
|
||||
this->clipFar = ctx.data["zFar"].get<float_t>();
|
||||
if(ctx->data.contains("clipFar")) {
|
||||
this->clipFar = ctx->data["clipFar"].get<float_t>();
|
||||
} else if(ctx->data.contains("far")) {
|
||||
this->clipFar = ctx->data["far"].get<float_t>();
|
||||
} else if(ctx->data.contains("zFar")) {
|
||||
this->clipFar = ctx->data["zFar"].get<float_t>();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -33,7 +33,7 @@ namespace Dawn {
|
||||
|
||||
void onInit() override;
|
||||
void onDispose() override;
|
||||
void load(SceneComponentLoadContext &ctx) override;
|
||||
void load(std::shared_ptr<SceneLoadContext> ctx) override;
|
||||
|
||||
/**
|
||||
* Returns the aspect ratio that the camera is using. In future I may
|
||||
|
@@ -9,14 +9,14 @@
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
void SimpleTexturedMaterial::load(SceneComponentLoadContext &ctx) {
|
||||
if(ctx.data.contains("color")) {
|
||||
this->setColor(JSON::color(ctx.data["color"]));
|
||||
void SimpleTexturedMaterial::load(std::shared_ptr<SceneLoadContext> ctx) {
|
||||
if(ctx->data.contains("color")) {
|
||||
this->setColor(JSON::color(ctx->data["color"]));
|
||||
}
|
||||
|
||||
if(ctx.data.contains("texture")) {
|
||||
auto asset = ctx.getAsset<TextureLoader>(
|
||||
ctx.data["texture"].get<std::string>()
|
||||
if(ctx->data.contains("texture")) {
|
||||
auto asset = ctx->getAsset<TextureLoader>(
|
||||
ctx->data["texture"].get<std::string>()
|
||||
);
|
||||
this->setTexture(asset->getTexture());
|
||||
}
|
||||
|
@@ -15,7 +15,7 @@ namespace Dawn {
|
||||
std::shared_ptr<Texture> texture;
|
||||
|
||||
public:
|
||||
void load(SceneComponentLoadContext &ctx) override;
|
||||
void load(std::shared_ptr<SceneLoadContext> ctx) override;
|
||||
|
||||
/**
|
||||
* Returns the color of this material.
|
||||
|
@@ -10,10 +10,7 @@
|
||||
using namespace Dawn;
|
||||
|
||||
void CubeMeshComponent::onInit() {
|
||||
if(!mesh) {
|
||||
mesh = std::make_shared<Mesh>();
|
||||
}
|
||||
|
||||
if(!mesh) mesh = std::make_shared<Mesh>();
|
||||
mesh->createBuffers(CUBE_VERTICE_COUNT, CUBE_INDICE_COUNT);
|
||||
CubeMesh::buffer(
|
||||
mesh, glm::vec3(-0.5f, -0.5f, -0.5f), glm::vec3(1.0f, 1.0f, 1.0f), 0, 0
|
||||
@@ -27,7 +24,7 @@ void CubeMeshComponent::onDispose() {
|
||||
mesh = nullptr;
|
||||
}
|
||||
|
||||
void CubeMeshComponent::load(SceneComponentLoadContext &ctx) {
|
||||
void CubeMeshComponent::load(std::shared_ptr<SceneLoadContext> ctx) {
|
||||
SceneComponent::load(ctx);
|
||||
if(!mesh) mesh = std::make_shared<Mesh>();
|
||||
|
||||
}
|
@@ -14,6 +14,6 @@ namespace Dawn {
|
||||
|
||||
void onInit() override;
|
||||
void onDispose() override;
|
||||
void load(SceneComponentLoadContext &ctx) override;
|
||||
void load(std::shared_ptr<SceneLoadContext> ctx) override;
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user