Working on adding Eigen
This commit is contained in:
1 parent
c553780b6e
commit
9bfe2bef89
16 files changed
+402
-503
No files matched your search
+49
-45
@@ -50,10 +50,10 @@ namespace ZL {
|
||||
|
||||
Vector2f posTo = center + halfWidthHeight;
|
||||
|
||||
Vector3f pos1 = { posFrom.v[0], posFrom.v[1], zLevel };
|
||||
Vector3f pos2 = { posFrom.v[0], posTo.v[1], zLevel };
|
||||
Vector3f pos3 = { posTo.v[0], posTo.v[1], zLevel };
|
||||
Vector3f pos4 = { posTo.v[0], posFrom.v[1], zLevel };
|
||||
Vector3f pos1 = { posFrom(0), posFrom(1), zLevel };
|
||||
Vector3f pos2 = { posFrom(0), posTo(1), zLevel };
|
||||
Vector3f pos3 = { posTo(0), posTo(1), zLevel };
|
||||
Vector3f pos4 = { posTo(0), posFrom(1), zLevel };
|
||||
|
||||
|
||||
Vector2f texCoordPos1 = { 0.0f, 0.0f };
|
||||
@@ -86,16 +86,16 @@ namespace ZL {
|
||||
|
||||
Vector2f posTo = center + halfWidthHeight;
|
||||
|
||||
float sectionWidth = halfWidthHeight.v[0] * 2.f;
|
||||
float sectionWidth = halfWidthHeight(0) * 2.f;
|
||||
|
||||
VertexDataStruct result;
|
||||
|
||||
for (size_t i = 0; i < sectionCount; i++)
|
||||
{
|
||||
Vector3f pos1 = { posFrom.v[0]+sectionWidth*i, posFrom.v[1], zLevel };
|
||||
Vector3f pos2 = { posFrom.v[0] + sectionWidth * i, posTo.v[1], zLevel };
|
||||
Vector3f pos3 = { posTo.v[0] + sectionWidth * i, posTo.v[1], zLevel };
|
||||
Vector3f pos4 = { posTo.v[0] + sectionWidth * i, posFrom.v[1], zLevel };
|
||||
Vector3f pos1 = { posFrom(0)+sectionWidth*i, posFrom(1), zLevel };
|
||||
Vector3f pos2 = { posFrom(0) + sectionWidth * i, posTo(1), zLevel };
|
||||
Vector3f pos3 = { posTo(0) + sectionWidth * i, posTo(1), zLevel };
|
||||
Vector3f pos4 = { posTo(0) + sectionWidth * i, posFrom(1), zLevel };
|
||||
|
||||
result.PositionData.push_back(pos1);
|
||||
result.PositionData.push_back(pos2);
|
||||
@@ -362,9 +362,9 @@ namespace ZL {
|
||||
{
|
||||
for (int i = 0; i < PositionData.size(); i++)
|
||||
{
|
||||
auto value = PositionData[i].v[1];
|
||||
PositionData[i].v[1] = PositionData[i].v[2];
|
||||
PositionData[i].v[2] = value;
|
||||
auto value = PositionData[i](1);
|
||||
PositionData[i](1) = PositionData[i](2);
|
||||
PositionData[i](2) = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -493,11 +493,11 @@ namespace ZL {
|
||||
|
||||
static const std::string ProjectionModelViewMatrixName = "ProjectionModelViewMatrix";
|
||||
|
||||
RenderUniformMatrix4fv(ProjectionModelViewMatrixName, false, &ProjectionModelViewMatrix.m[0]);
|
||||
RenderUniformMatrix4fv(ProjectionModelViewMatrixName, false, ProjectionModelViewMatrix.data());
|
||||
|
||||
static const std::string ModelViewMatrixName = "ModelViewMatrix";
|
||||
|
||||
RenderUniformMatrix4fv(ModelViewMatrixName, false, &modelViewMatrix.m[0]);
|
||||
RenderUniformMatrix4fv(ModelViewMatrixName, false, modelViewMatrix.data());
|
||||
|
||||
}
|
||||
|
||||
@@ -533,9 +533,9 @@ namespace ZL {
|
||||
{
|
||||
|
||||
Matrix4f m = Matrix4f::Identity();
|
||||
m.m[12] = p.v[0];
|
||||
m.m[13] = p.v[1];
|
||||
m.m[14] = p.v[2];
|
||||
m.data()[12] = p(0);
|
||||
m.data()[13] = p(1);
|
||||
m.data()[14] = p(2);
|
||||
|
||||
m = ModelviewMatrixStack.top() * m;
|
||||
|
||||
@@ -553,9 +553,9 @@ namespace ZL {
|
||||
void Renderer::ScaleMatrix(float scale)
|
||||
{
|
||||
Matrix4f m = Matrix4f::Identity();
|
||||
m.m[0] = scale;
|
||||
m.m[5] = scale;
|
||||
m.m[10] = scale;
|
||||
m.data()[0] = scale;
|
||||
m.data()[5] = scale;
|
||||
m.data()[10] = scale;
|
||||
|
||||
m = ModelviewMatrixStack.top() * m;
|
||||
|
||||
@@ -573,9 +573,9 @@ namespace ZL {
|
||||
void Renderer::ScaleMatrix(const Vector3f& scale)
|
||||
{
|
||||
Matrix4f m = Matrix4f::Identity();
|
||||
m.m[0] = scale.v[0];
|
||||
m.m[5] = scale.v[1];
|
||||
m.m[10] = scale.v[2];
|
||||
m.data()[0] = scale(0);
|
||||
m.data()[5] = scale(1);
|
||||
m.data()[10] = scale(2);
|
||||
|
||||
m = ModelviewMatrixStack.top() * m;
|
||||
|
||||
@@ -590,23 +590,26 @@ namespace ZL {
|
||||
SetMatrix();
|
||||
}
|
||||
|
||||
void Renderer::RotateMatrix(const Vector4f& q)
|
||||
void Renderer::RotateMatrix(const Eigen::Quaternionf& q)
|
||||
{
|
||||
|
||||
Matrix3f m3 = QuatToMatrix(q);
|
||||
Matrix4f m = Matrix4f::Identity();
|
||||
m.m[0] = m3.m[0];
|
||||
m.m[1] = m3.m[1];
|
||||
m.m[2] = m3.m[2];
|
||||
|
||||
m.m[4] = m3.m[3];
|
||||
m.m[5] = m3.m[4];
|
||||
m.m[6] = m3.m[5];
|
||||
m.block<3, 3>(0, 0) = m3;
|
||||
/*
|
||||
m.m[0] = m3.data()[0];
|
||||
m.m[1] = m3.data()[1];
|
||||
m.m[2] = m3.data()[2];
|
||||
|
||||
m.m[8] = m3.m[6];
|
||||
m.m[9] = m3.m[7];
|
||||
m.m[10] = m3.m[8];
|
||||
m.m[4] = m3.data()[3];
|
||||
m.m[5] = m3.data()[4];
|
||||
m.m[6] = m3.data()[5];
|
||||
|
||||
m.m[8] = m3.data()[6];
|
||||
m.m[9] = m3.data()[7];
|
||||
m.m[10] = m3.data()[8];
|
||||
*/
|
||||
m = ModelviewMatrixStack.top() * m;
|
||||
|
||||
if (ModelviewMatrixStack.size() == 0)
|
||||
@@ -624,17 +627,18 @@ namespace ZL {
|
||||
void Renderer::RotateMatrix(const Matrix3f& m3)
|
||||
{
|
||||
Matrix4f m = Matrix4f::Identity();
|
||||
m.m[0] = m3.m[0];
|
||||
m.m[1] = m3.m[1];
|
||||
m.m[2] = m3.m[2];
|
||||
/*m.m[0] = m3.data()[0];
|
||||
m.m[1] = m3.data()[1];
|
||||
m.m[2] = m3.data()[2];
|
||||
|
||||
m.m[4] = m3.m[3];
|
||||
m.m[5] = m3.m[4];
|
||||
m.m[6] = m3.m[5];
|
||||
m.m[4] = m3.data()[3];
|
||||
m.m[5] = m3.data()[4];
|
||||
m.m[6] = m3.data()[5];
|
||||
|
||||
m.m[8] = m3.m[6];
|
||||
m.m[9] = m3.m[7];
|
||||
m.m[10] = m3.m[8];
|
||||
m.m[8] = m3.data()[6];
|
||||
m.m[9] = m3.data()[7];
|
||||
m.m[10] = m3.data()[8];*/
|
||||
m.block<3, 3>(0, 0) = m3;
|
||||
|
||||
m = ModelviewMatrixStack.top() * m;
|
||||
|
||||
@@ -818,11 +822,11 @@ namespace ZL {
|
||||
int screenWidth, int screenHeight,
|
||||
int& screenX, int& screenY) {
|
||||
|
||||
Vector4f inx = { objectPos.v[0], objectPos.v[1], objectPos.v[2], 1.0f };
|
||||
Vector4f inx = { objectPos(0), objectPos(1), objectPos(2), 1.0f };
|
||||
Vector4f clipCoords = MultMatrixVector(projectionModelView, inx);
|
||||
|
||||
float ndcX = clipCoords.v[0] / clipCoords.v[3];
|
||||
float ndcY = clipCoords.v[1] / clipCoords.v[3];
|
||||
float ndcX = clipCoords(0) / clipCoords(3);
|
||||
float ndcY = clipCoords(1) / clipCoords(3);
|
||||
|
||||
screenX = (int)((ndcX + 1.0f) * 0.5f * screenWidth);
|
||||
screenY = (int)((1.0f + ndcY) * 0.5f * screenHeight);
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace ZL {
|
||||
void TranslateMatrix(const Vector3f& p);
|
||||
void ScaleMatrix(float scale);
|
||||
void ScaleMatrix(const Vector3f& scale);
|
||||
void RotateMatrix(const Vector4f& q);
|
||||
void RotateMatrix(const Eigen::Quaternionf& q);
|
||||
void RotateMatrix(const Matrix3f& m3);
|
||||
void PushSpecialMatrix(const Matrix4f& m);
|
||||
void PopMatrix();
|
||||
|
||||
Reference in new issue
Block a user