【发布时间】:2013-11-04 14:16:24
【问题描述】:
我想用 OpenGL 绘制我的平面来调试我的程序,但我不知道该怎么做(我数学不太好)。
我有一个有 2 个属性的飞机:
- 一个常数
- 正常
这是我得到的:
////////////////////////////////////////////////////////////
Plane::Plane( const glm::vec3& a, const glm::vec3& b, const glm::vec3& c )
{
glm::vec3 edge1 = b - a;
glm::vec3 edge2 = c - a;
this->normal = glm::cross(edge1, edge2);
this->constant = -glm::dot( this->normal, a );
this->normalize();
}
////////////////////////////////////////////////////////////
Plane::Plane( const glm::vec4& values )
{
this->normal = glm::vec3( values.x, values.y, values.z );
this->constant = values.w;
}
////////////////////////////////////////////////////////////
Plane::Plane( const glm::vec3& normal, const float constant ) :
constant (constant),
normal (normal)
{
}
////////////////////////////////////////////////////////////
Plane::Plane( const glm::vec3& normal, const glm::vec3& point )
{
this->normal = normal;
this->constant = -glm::dot(normal, point);
this->normalize();
}
我想把它画出来看看是否一切正常。我怎么能这样做? (我需要计算顶点和索引来绘制它)
【问题讨论】: