本文整理汇总了C++中Matrix4::Transform方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix4::Transform方法的具体用法?C++ Matrix4::Transform怎么用?C++ Matrix4::Transform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix4
的用法示例。
在下文中一共展示了Matrix4::Transform方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LocalRotate
void Camera::LocalRotate( float x, float y )
{
Matrix4 viewSpaceRotation;
MakeRotationMatrixX(viewSpaceRotation, x);
Matrix4 viewSpaceRotationY;
MakeRotationMatrixY(viewSpaceRotationY, y);
MatrixMultiply(viewSpaceRotation, viewSpaceRotation, viewSpaceRotationY);
Vector4& newViewDirection = viewSpaceRotation.Transform(Vector3(0.0f, 0.0f, 1.0f));
Matrix4 cameraRotation = GetViewMatrix();
cameraRotation.m41 = cameraRotation.m42 = cameraRotation.m43 = 0.0f;
Matrix4 inverseCameraRotation;
MatrixTranspose(inverseCameraRotation, cameraRotation);
Vector4& newWorldSpaceViewDir = inverseCameraRotation.Transform(newViewDirection);
Vector3 newWorldSpaceViewDir3;
newWorldSpaceViewDir3.x = newWorldSpaceViewDir.x;
newWorldSpaceViewDir3.y = newWorldSpaceViewDir.y;
newWorldSpaceViewDir3.z = newWorldSpaceViewDir.z;
newWorldSpaceViewDir3.Normalize();
m_position = m_lookAt - newWorldSpaceViewDir3 * m_distanceToLookAt;
Vector3 right = m_up.Cross(newWorldSpaceViewDir3);
m_up = newWorldSpaceViewDir3.Cross(right);
m_up.Normalize();
m_viewMatrixDirty = true;
}
示例2:
Vector3 Vector3::DirectionVector(const Vector3 &up, float rotX, float rotY, float rotZ)
{
Matrix4 rotMat = Matrix4::RotationYPRMatrix(rotY, rotX, rotZ);
Vector3 invUp = -up;
return rotMat.Transform(invUp);
}
示例3: CreateTestSceneFromModel
TestScene * CreateTestScene5(ViewSettings & viewSettings, String baseDir)
{
auto rs = CreateTestSceneFromModel(viewSettings, baseDir + L"/warehouse/ep2_indoor.obj");
Matrix4 modelView;
float transformMatrix[] = { -0.669132f, 0.023659f, -0.742766f, 0.000000f,
0.000000f, 0.999493f, 0.031837f, 0.000000f,
0.743143f, 0.021303f, -0.668793f, 0.000000f,
-7027.120605f, 1115.192993f, 6001.621094f, 1.000000f };
for (int i = 0; i < 16; i++)
modelView.values[i] = transformMatrix[i];
Matrix4 flip;
Matrix4::CreateIdentityMatrix(flip);
flip.m[1][1] = 0.0f;
flip.m[1][2] = -1.0f;
flip.m[2][1] = 1.0f;
flip.m[2][2] = 0.0f;
Matrix4 flipped;
Matrix4::Multiply(flipped, modelView, flip);
modelView = flipped;
rs->State.SetModelViewTransform(modelView);
auto shader = new LightingShader();
Light light;
Vec3 lightPos = Vec3(282.73f, -9336.99f, -1269.75f);
modelView.Transform(light.Position, lightPos);
light.Ambient = 0.2f;
light.Color = Vec3(1.65f, 1.65f, 1.70f);
light.Decay = 850.0f;
shader->Lights.Add(light);
lightPos = Vec3(-196.555801f, -9157.416992f, -1255.329346f);
modelView.Transform(light.Position, lightPos);
light.Ambient = 0.0f;
light.Color = Vec3(1.5f, 0.5f, 0.28f);
light.Decay = 400.0f;
shader->Lights.Add(light);
rs->SetShader(shader);
return rs;
}
示例4: TryUpdateVertex
bool IMesh::TryUpdateVertex(VertexGraphicsBuffer& bufferObject, size_t vertexIndex, const ICollection<Point3F>& vertices, const Matrix4& matrix) const
{
RETURN_TRUE_IF_EMPTY(vertices);
bufferObject.ReserveSize(vertexIndex, vertices.Count());
size_t count = vertices.Count();
const Point3F* verticesPtr = vertices.Items();
FOR_EACH_SIZE(i, count)
{
Point3F pos = matrix.Transform(verticesPtr[i]);
bufferObject.AppendOrUpdateData(vertexIndex + i, pos);
}
示例5: Project
Vector3F Viewport::Project(const Vector3F &source, const Matrix4 &projection, const Matrix4 &view, const Matrix4 &world)
{
Matrix4 mat = world * view * projection; // Matrix4::Multiply(Matrix4.Multiply(world, view), projection);
Vector3F vector;
mat.Transform(source, vector); // Vector3F::Transform(source, mat);
float a = (((source.x * mat.a14) + (source.y * mat.a24)) + (source.z * mat.a34)) + mat.a44;
if (!WithinEpsilon(a, 1.0f))
{
vector = (Vector3F) (vector / a);
}
vector.x = (((vector.x + 1.0f) * 0.5f) * m_Width) + m_X;
vector.y = (((-vector.y + 1.0f) * 0.5f) * m_Height) + m_Y;
vector.z = (vector.z * (m_fFarClipPlane - m_fNearClipPlane)) + m_fNearClipPlane;
return vector;
}
示例6: Unproject
Vector3F Viewport::Unproject(const Vector3F &source, const Matrix4 &projection, const Matrix4 &view, const Matrix4 &world)
{
Vector3F vector = source;
Matrix4 mat = (world * view * projection).Invert(); //Matrix4.Invert(Matrix4.Multiply(Matrix4.Multiply(world, view), projection));
vector.x = (((source.x - m_X) / ((float) m_Width)) * 2.0f) - 1.0f;
vector.y = -((((source.y - m_Y) / ((float) m_Height)) * 2.0f) - 1.0f);
vector.z = (source.z - m_fNearClipPlane) / (m_fFarClipPlane - m_fNearClipPlane);
mat.Transform(source, vector); // Vector3F.Transform(source, mat);
float a = (((source.x * mat.a14) + (source.y * mat.a24)) + (source.z * mat.a34)) + mat.a44;
if (!WithinEpsilon(a, 1.0f))
{
vector = (Vector3F) (vector / a);
}
return vector;
}
示例7: LocalMove
void Camera::LocalMove( float x, float y, float z )
{
Matrix4 rotationMatrix = GetViewMatrix();
rotationMatrix.m41 = rotationMatrix.m42 = rotationMatrix.m43 = 0.0f;
Matrix4 inverseRotationMatrix;
MatrixTranspose(inverseRotationMatrix, rotationMatrix);
Vector4 worldSpaceOffset = inverseRotationMatrix.Transform(Vector4(x, y, z, 1.0f));
m_position.x += worldSpaceOffset.x;
m_position.y += worldSpaceOffset.y;
m_position.z += worldSpaceOffset.z;
m_lookAt.x += worldSpaceOffset.x;
m_lookAt.y += worldSpaceOffset.y;
m_lookAt.z += worldSpaceOffset.z;
m_viewMatrixDirty = true;
}