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