render obj file
This commit is contained in:
@@ -13,22 +13,57 @@ namespace Archimedes {
|
||||
|
||||
public:
|
||||
|
||||
Object() {};
|
||||
|
||||
Object(glm::mat4 t)
|
||||
: worldTransform(t) {}
|
||||
|
||||
~Object() {};
|
||||
|
||||
///scales an object absolutely
|
||||
//void scaleTo() {}
|
||||
void scaleRel(float scale) { worldTransform = glm::scale(worldTransform, glm::vec3(scale)); }
|
||||
///scale factors less than zero do nothing
|
||||
float scaleTo(float s) {
|
||||
if(s > 0) {
|
||||
worldTransform = glm::scale(worldTransform, glm::vec3(s / scale));
|
||||
scale = s;
|
||||
}
|
||||
|
||||
//void moveTo(glm::vec3 pos) { worldTransform = glm::translate(worldTransform, pos); }
|
||||
void moveRel(glm::vec3 pos) { worldTransform = glm::translate(worldTransform, pos); }
|
||||
return scale;
|
||||
}
|
||||
|
||||
//void rotateTo() {}
|
||||
void rotateRel(float radians, glm::vec3 axis) { worldTransform = glm::rotate(worldTransform, radians, axis); }
|
||||
float scaleRel(float s) {
|
||||
return scaleTo(scale * s);
|
||||
}
|
||||
|
||||
float scaleAdd(float s) {
|
||||
return scaleTo(scale + s);
|
||||
}
|
||||
|
||||
glm::vec3 moveTo(glm::vec3 pos) {
|
||||
worldTransform = glm::translate(worldTransform, pos - position);
|
||||
position = pos;
|
||||
|
||||
return position;
|
||||
}
|
||||
|
||||
glm::vec3 moveRel(glm::vec3 pos) {
|
||||
return moveTo(pos + position);
|
||||
}
|
||||
|
||||
glm::vec3 rotateTo(glm::vec3 angles) {
|
||||
worldTransform = glm::rotate(worldTransform, angles.x - rotation.x, glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
worldTransform = glm::rotate(worldTransform, angles.y - rotation.y, glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
worldTransform = glm::rotate(worldTransform, angles.z - rotation.z, glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
rotation = angles;
|
||||
|
||||
return rotation;
|
||||
}
|
||||
|
||||
glm::vec3 rotateRel(glm::vec3 angles) {
|
||||
return rotateTo(angles + rotation);
|
||||
}
|
||||
|
||||
glm::vec3& getPosition() { return position; }
|
||||
glm::vec3& getRotation() { return rotation; }
|
||||
float& getScale() { return scale; }
|
||||
|
||||
const glm::mat4& getTransform() { return worldTransform; }
|
||||
|
||||
@@ -36,6 +71,7 @@ namespace Archimedes {
|
||||
|
||||
glm::vec3 position = glm::vec3(0);
|
||||
glm::vec3 rotation = glm::vec3(0);
|
||||
float scale = 1.0f;
|
||||
|
||||
glm::mat4 worldTransform = glm::mat4(1.0f);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user