-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
173 changed files
with
38,770 additions
and
330 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#ifndef GMATRIX_H | ||
#define GMATRIX_H | ||
|
||
#include "gincu/ggeometry.h" | ||
#include "glm/mat4x4.hpp" | ||
#include "glm/gtc/matrix_transform.hpp" | ||
#include "glm/gtc/matrix_inverse.hpp" | ||
|
||
namespace gincu { | ||
|
||
typedef glm::mat4 GMatrix44; | ||
|
||
inline GMatrix44 translateMatrix(const GMatrix44 & matrix, const GPoint & p) | ||
{ | ||
return glm::translate(matrix, { p.x, p.y, 0 }); | ||
} | ||
|
||
inline GMatrix44 scaleMatrix(const GMatrix44 & matrix, const GScale & scale) | ||
{ | ||
return glm::scale(matrix, { scale.x, scale.y, 1 }); | ||
} | ||
|
||
inline GMatrix44 inverseMatrix(const GMatrix44 & matrix) | ||
{ | ||
return glm::inverse(matrix); | ||
} | ||
|
||
inline GPoint transformPoint(const GMatrix44 & matrix, const GPoint & point) | ||
{ | ||
auto p = matrix * glm::vec4 { point.x, point.y, 0, 1 }; | ||
return { p.x, p.y }; | ||
} | ||
|
||
|
||
} //namespace gincu | ||
|
||
|
||
|
||
|
||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,59 @@ | ||
#include "gincu/sfml/gtransform.h" | ||
#ifndef GTRANSFORM_H | ||
#define GTRANSFORM_H | ||
|
||
#include "gincu/ggeometry.h" | ||
#include "gincu/grenderanchor.h" | ||
#include "gincu/gmatrix.h" | ||
|
||
#include "cpgf/gflags.h" | ||
|
||
namespace gincu { | ||
|
||
class GTransform | ||
{ | ||
private: | ||
enum class Flags { | ||
flagDirty = 1 << 0, | ||
flagProjection = 1 << 1 | ||
}; | ||
|
||
public: | ||
GTransform(); | ||
explicit GTransform(const GPoint & position, const GScale & scale = {1.0f, 1.0f}); | ||
explicit GTransform(const GMatrix44 & matrix); | ||
|
||
GPoint getPosition() const; | ||
void setPosition(const GPoint & position); | ||
|
||
GPoint getOrigin() const; | ||
void setOrigin(const GPoint & origin); | ||
|
||
GScale getScale() const; | ||
void setScale(const GScale & scale); | ||
|
||
float getRotation() const; | ||
void setRotation(const float rotation); | ||
|
||
const GMatrix44 & getMatrix() const; | ||
|
||
void setProjectionMode(const bool projectionMode) const; | ||
|
||
private: | ||
void doUpdateTransform() const; | ||
|
||
bool isProjectionMode() const { return this->flags.has(Flags::flagProjection); } | ||
|
||
private: | ||
GPoint position; | ||
GPoint origin; | ||
GScale scaleValue; | ||
float rotation; // degree | ||
mutable cpgf::GFlags<Flags> flags; | ||
mutable GMatrix44 matrix; | ||
}; | ||
|
||
|
||
} //namespace gincu | ||
|
||
|
||
#endif |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.