mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-06-04 18:54:00 +08:00
opengl demo: add aligned operator new where appropriate and remove my
mess...
This commit is contained in:
parent
c6264d9b7e
commit
312994fa98
@ -32,6 +32,8 @@
|
|||||||
class Frame
|
class Frame
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
|
||||||
|
|
||||||
inline Frame(const Eigen::Vector3f& pos = Eigen::Vector3f::Zero(),
|
inline Frame(const Eigen::Vector3f& pos = Eigen::Vector3f::Zero(),
|
||||||
const Eigen::Quaternionf& o = Eigen::Quaternionf())
|
const Eigen::Quaternionf& o = Eigen::Quaternionf())
|
||||||
: orientation(o), position(pos)
|
: orientation(o), position(pos)
|
||||||
@ -49,6 +51,7 @@ class Frame
|
|||||||
class Camera
|
class Camera
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
|
||||||
|
|
||||||
Camera(void);
|
Camera(void);
|
||||||
|
|
||||||
|
@ -44,6 +44,8 @@ using namespace Eigen;
|
|||||||
class FancySpheres
|
class FancySpheres
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
|
||||||
|
|
||||||
FancySpheres()
|
FancySpheres()
|
||||||
{
|
{
|
||||||
const int levels = 4;
|
const int levels = 4;
|
||||||
@ -262,67 +264,18 @@ void RenderingWidget::drawScene()
|
|||||||
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, Vector4f(1, 1, 1, 1).data());
|
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, Vector4f(1, 1, 1, 1).data());
|
||||||
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 64);
|
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 64);
|
||||||
|
|
||||||
// glEnable(GL_LIGHTING);
|
glEnable(GL_LIGHTING);
|
||||||
// glEnable(GL_LIGHT0);
|
glEnable(GL_LIGHT0);
|
||||||
// glEnable(GL_LIGHT1);
|
glEnable(GL_LIGHT1);
|
||||||
|
|
||||||
glColor3f(0.4, 0.7, 0.4);
|
sFancySpheres.draw();
|
||||||
|
glVertexPointer(3, GL_FLOAT, 0, mVertices[0].data());
|
||||||
{IcoSphere s(5);
|
glNormalPointer(GL_FLOAT, 0, mNormals[0].data());
|
||||||
float length = 6;
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
// const std::vector<int>& indices = s.indices(2);
|
glEnableClientState(GL_NORMAL_ARRAY);
|
||||||
for (unsigned int i=0; i<s.vertices().size() ; ++i)
|
glDrawArrays(GL_TRIANGLES, 0, mVertices.size());
|
||||||
{
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
Vector3f n = s.vertices()[i].normalized();
|
glDisableClientState(GL_NORMAL_ARRAY);
|
||||||
Vector3f p = n*100;
|
|
||||||
|
|
||||||
int i,j;
|
|
||||||
float minc = n.minCoeff(&i);
|
|
||||||
float maxc = n.maxCoeff(&j);
|
|
||||||
Vector3f o = n;
|
|
||||||
o[i] = -n[j];
|
|
||||||
o[j] = n[i];
|
|
||||||
|
|
||||||
//Vector3f u = n.unitOrthogonal().normalized();
|
|
||||||
Vector3f u = n.cross(o).normalized();
|
|
||||||
Vector3f v = n.cross(u).normalized();
|
|
||||||
gpu.drawVector(p, length*u, Color(1,0,0,1));
|
|
||||||
gpu.drawVector(p, length*v, Color(0,1,0,1));
|
|
||||||
// gpu.drawVector(p, length*n, Color(0,0,1,1));
|
|
||||||
}}
|
|
||||||
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
Vector3f n = Vector3f::Random().normalized();
|
|
||||||
// Vector3f p = n*100;
|
|
||||||
//Vector3f u = n.unitOrthogonal().normalized();
|
|
||||||
// int i,j;
|
|
||||||
// float minc = n.minCoeff(&i);
|
|
||||||
// float maxc = n.maxCoeff(&j);
|
|
||||||
|
|
||||||
// Vector3f o = n;
|
|
||||||
// o[i] = -n[j];
|
|
||||||
// o[j] = n[i];
|
|
||||||
Vector3f o = Vector3f(-n.y(),n.z(),n.x()).normalized();
|
|
||||||
Vector3f u = n.cross(o).normalized();
|
|
||||||
|
|
||||||
float d = ei_abs(o.dot(n));
|
|
||||||
|
|
||||||
if (d>0.9999)
|
|
||||||
std::cout << d << " " << n.transpose() << "\n";
|
|
||||||
|
|
||||||
// Vector3f v = n.cross(u).normalized();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// sFancySpheres.draw();
|
|
||||||
// glVertexPointer(3, GL_FLOAT, 0, mVertices[0].data());
|
|
||||||
// glNormalPointer(GL_FLOAT, 0, mNormals[0].data());
|
|
||||||
// glEnableClientState(GL_VERTEX_ARRAY);
|
|
||||||
// glEnableClientState(GL_NORMAL_ARRAY);
|
|
||||||
// glDrawArrays(GL_TRIANGLES, 0, mVertices.size());
|
|
||||||
// glDisableClientState(GL_VERTEX_ARRAY);
|
|
||||||
// glDisableClientState(GL_NORMAL_ARRAY);
|
|
||||||
|
|
||||||
glDisable(GL_LIGHTING);
|
glDisable(GL_LIGHTING);
|
||||||
}
|
}
|
||||||
|
@ -109,6 +109,8 @@ class RenderingWidget : public QGLWidget
|
|||||||
//--------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
|
||||||
|
|
||||||
RenderingWidget();
|
RenderingWidget();
|
||||||
~RenderingWidget() { }
|
~RenderingWidget() { }
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user