Added scaling
This commit is contained in:
parent
391060d9ba
commit
4955d77de8
@ -3,13 +3,22 @@
|
|||||||
Transform::Transform() {
|
Transform::Transform() {
|
||||||
position = Vector3(0.0f);
|
position = Vector3(0.0f);
|
||||||
rotation = Vector3(0.0f);
|
rotation = Vector3(0.0f);
|
||||||
|
scale = Vector3(1.0f, 1.0f, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
Transform::Transform(Vector3 position, Vector3 rotation) {
|
Transform::Transform(Vector3 position, Vector3 rotation) {
|
||||||
this->position = position;
|
this->position = position;
|
||||||
this->rotation = rotation;
|
this->rotation = rotation;
|
||||||
|
this->scale = Vector3(1.0f, 1.0f, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Transform::Transform(Vector3 position, Vector3 rotation, Vector3 scale) {
|
||||||
|
this->position = position;
|
||||||
|
this->rotation = rotation;
|
||||||
|
this->scale = scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Transform::Translate(cfloat x, cfloat y, cfloat z) {
|
void Transform::Translate(cfloat x, cfloat y, cfloat z) {
|
||||||
position = position + Vector3(x, y, z);
|
position = position + Vector3(x, y, z);
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,10 @@
|
|||||||
struct Transform {
|
struct Transform {
|
||||||
Transform();
|
Transform();
|
||||||
Transform(Vector3 position, Vector3 rotation);
|
Transform(Vector3 position, Vector3 rotation);
|
||||||
|
Transform(Vector3 position, Vector3 rotation, Vector3 scale);
|
||||||
Vector3 position;
|
Vector3 position;
|
||||||
Vector3 rotation;
|
Vector3 rotation;
|
||||||
|
Vector3 scale;
|
||||||
void Translate(cfloat x, cfloat y, cfloat z);
|
void Translate(cfloat x, cfloat y, cfloat z);
|
||||||
Vector3 Forward();
|
Vector3 Forward();
|
||||||
};
|
};
|
||||||
|
@ -38,6 +38,7 @@ void render(Node *curr, Shader *shader, Matrix model) {
|
|||||||
model = glm::rotate(model, spatial->transform.rotation.y, Vector3(0.0f, 1.0f, 0.0f));
|
model = glm::rotate(model, spatial->transform.rotation.y, Vector3(0.0f, 1.0f, 0.0f));
|
||||||
model = glm::rotate(model, spatial->transform.rotation.z, Vector3(0.0f, 0.0f, 1.0f));
|
model = glm::rotate(model, spatial->transform.rotation.z, Vector3(0.0f, 0.0f, 1.0f));
|
||||||
model = glm::translate(model, spatial->transform.position);
|
model = glm::translate(model, spatial->transform.position);
|
||||||
|
model = glm::scale(model, spatial->transform.scale);
|
||||||
shader->UpdateModel(model);
|
shader->UpdateModel(model);
|
||||||
}
|
}
|
||||||
Mesh *mesh = dynamic_cast<Mesh*>(curr);
|
Mesh *mesh = dynamic_cast<Mesh*>(curr);
|
||||||
|
@ -49,6 +49,7 @@ function init()
|
|||||||
trough = couch.TexturedMesh("trough.glb", "wood_lowres.png")
|
trough = couch.TexturedMesh("trough.glb", "wood_lowres.png")
|
||||||
couch.Node.GetRoot().children:Append(trough)
|
couch.Node.GetRoot().children:Append(trough)
|
||||||
trough.transform:Translate(10.0, 0.0, 0.0)
|
trough.transform:Translate(10.0, 0.0, 0.0)
|
||||||
|
trough.transform.scale = trough.transform.scale * 3.0
|
||||||
|
|
||||||
scaffold = couch.TexturedMesh("scaffold.glb", "grate_floor_lowres.png", "railing.png")
|
scaffold = couch.TexturedMesh("scaffold.glb", "grate_floor_lowres.png", "railing.png")
|
||||||
couch.Node.GetRoot().children:Append(scaffold)
|
couch.Node.GetRoot().children:Append(scaffold)
|
||||||
|
Loading…
Reference in New Issue
Block a user