本文整理汇总了C++中Matrix4x4::GetColumn方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix4x4::GetColumn方法的具体用法?C++ Matrix4x4::GetColumn怎么用?C++ Matrix4x4::GetColumn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix4x4
的用法示例。
在下文中一共展示了Matrix4x4::GetColumn方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Construct
//生成6个面 clip 是 wvp matrix
/////////////////////////
void Frustum::Construct(Matrix4x4 & clip)
{
Vector4 & column1(clip.GetColumn(0));
Vector4 & column2(clip.GetColumn(1));
Vector4 & column3(clip.GetColumn(2));
Vector4 & column4(clip.GetColumn(3));
//根据平面方程
//Near: (P0,P4,P5) n=(0,0,-1),d=0 0x+0y-1z+0=0
m_planes[0] = column4 - column3;//这个函数规格化平面方程,使|a,b,c| == 1。
//Far: (P2,P6,P7) n=(0,0,1),d=-1 0x+0y+1z-1=0
m_planes[1] = column4 + column3;
//Left: (P0,P3,P7) n=(-1,0,0),d=-1 -1x+0y+0z-1=0
m_planes[2] = column4 - column1;
//Right: (P1,P5,P6) n=(1,0,0),d=-1 1x+0y+0z-1=0
m_planes[3] = column4 + column1;
//Top: (P4,P7,P6) n=(0,1,0),d=-1 0x+1y+0z-1=0
m_planes[4] = column4 + column2;
//Bottom: (P0,P1,P2) n=(0,-1,0),d=-1 0x-1y+0z-1=0
m_planes[5] = column4 - column2;
//归一
for(int i=0; i<6; i++)
{
m_planes[i].Normalize();
}
//做个标记???
// build a bit-field that will tell us the indices for the nearest and farthest vertices from each plane...
for(int i=0; i<6; i++)
{
m_flag[i] = ((m_planes[i].x<0) ? 1 : 0) | ((m_planes[i].y<0) ? 2 : 0) | ((m_planes[i].z) ? 4 : 0);
}
}
示例2: AddVertex
void CToyUtil::AddVertex(size_t iMaterial, const Vector& vecPosition, const Vector2D& vecUV, const Matrix4x4& mNormals)
{
m_aaflData[iMaterial].push_back(vecPosition.x);
m_aaflData[iMaterial].push_back(vecPosition.y);
m_aaflData[iMaterial].push_back(vecPosition.z);
if (m_bUseUV)
{
m_aaflData[iMaterial].push_back(vecUV.x);
m_aaflData[iMaterial].push_back(vecUV.y);
}
if (m_bUseNormals)
{
m_aaflData[iMaterial].push_back(mNormals.GetColumn(0).x);
m_aaflData[iMaterial].push_back(mNormals.GetColumn(0).y);
m_aaflData[iMaterial].push_back(mNormals.GetColumn(0).z);
m_aaflData[iMaterial].push_back(mNormals.GetColumn(1).x);
m_aaflData[iMaterial].push_back(mNormals.GetColumn(1).y);
m_aaflData[iMaterial].push_back(mNormals.GetColumn(1).z);
m_aaflData[iMaterial].push_back(mNormals.GetColumn(2).x);
m_aaflData[iMaterial].push_back(mNormals.GetColumn(2).y);
m_aaflData[iMaterial].push_back(mNormals.GetColumn(2).z);
}
for (int i = 0; i < 3; i++)
{
if (vecPosition[i] < m_aabbVisBounds.m_vecMins[i])
m_aabbVisBounds.m_vecMins[i] = vecPosition[i];
if (vecPosition[i] > m_aabbVisBounds.m_vecMaxs[i])
m_aabbVisBounds.m_vecMaxs[i] = vecPosition[i];
}
}
示例3: main
int main()
{
using namespace icarus::graphics;
using namespace icarus::maths;
std::cout << "Hello World!" << std::endl;
#if 0
std::cout << (1 - 0.3f) << std::endl;
Vector4 vec(10, 10, 12, 5);
Vector4 vec2(5, 5, 8, 9.3f);
std::cout << vec << std::endl;
std::cout << vec2 << std::endl;
std::cout << vec + vec2 << std::endl;
std::cout << vec * vec2 << std::endl;
std::cout << vec * 2.5f << std::endl;
std::cout << (vec == vec2) << std::endl;
std::cout << "----------------------" << std::endl;
std::cout << vec << std::endl;
vec *= 5;
std::cout << vec << std::endl;
std::cout << (vec *= 2) << std::endl;
std::cout << vec << std::endl;
std::cout << "----------------------" << std::endl;
Matrix4x4 mat = Matrix4x4::Identity();
Matrix4x4 mat2 = Matrix4x4::Identity();
std::cout << (mat * mat2) << std::endl;
std::cout << "----------------------" << std::endl;
Matrix4x4 position = Matrix4x4::Translate(2, 3, 4);
std::cout << position << std::endl;
Vector4& column = position.GetColumn(3);
std::cout << column << std::endl;
std::cout << position.elements[12] << std::endl;
column.x++;
std::cout << position.elements[12] << std::endl;
#endif
if (!glfwInit()) {
return -1;
}
Window window("Game Engine", WIDTH, HEIGHT, true);
std::cout << glGetString(GL_VERSION) << std::endl;
{
glClearColor(0.0f, 0.5f, 0.8f, 1.0f);
GLfloat vertices[] =
{
//-0.5f, -0.5f, 0,
//-0.5f, 0.5f, 0,
// 0.5f, 0.5f, 0,
// 0.5f, 0.5f, 0,
// 0.5f, -0.5f, 0,
//-0.5f, -0.5f, 0,
0, 0, 0, // 0
0, 3, 0, // 1
8, 3, 0, // 2
8, 0, 0, // 3
};
GLuint indicies[] =
{
0, 1, 2,
2, 3, 0,
};
VertexArray va;
VertexBuffer vb(vertices, 4 * 3 * sizeof(GLfloat));
VertexBufferLayout layout;
layout.Push<float>(3);
va.AddBuffer(vb, layout);
IndexBuffer ib(indicies, 6);
Shader shader("src/shaders/Basic.shader");
Matrix4x4 model(1.0f);
//model *= Matrix4x4::Rotate(45, 0, 0, 1);
//model *= Matrix4x4::Scale(1, 0.5f, 1);
//model *= Matrix4x4::Translate(4, 3, 0);
//model = Matrix4x4::Identity();
Matrix4x4 view = Matrix4x4::Identity();
Matrix4x4 proj = Matrix4x4::Orthographic(0, 16, 0, 9, -1, 1);
shader.Bind();
shader.SetUniformMat4f("u_MVP", proj * view * model);
shader.SetUniform4f("u_Color", Vector4(0.2f, 0.3f, 0.8f, 1.0f));
shader.SetUniform2f("u_LightPos", Vector2(4, 1.5f));
Renderer renderer;
//.........这里部分代码省略.........