|
@@ -1,12 +1,13 @@
|
|
|
// This file is part of libigl, a simple c++ geometry processing library.
|
|
|
-//
|
|
|
+//
|
|
|
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
|
|
-//
|
|
|
-// This Source Code Form is subject to the terms of the Mozilla Public License
|
|
|
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
|
|
+//
|
|
|
+// This Source Code Form is subject to the terms of the Mozilla Public License
|
|
|
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
|
|
// obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
#include "project.h"
|
|
|
#ifndef IGL_NO_OPENGL
|
|
|
+#ifndef IGL_OPENGL_4
|
|
|
#include <iostream>
|
|
|
#include "report_gl_error.h"
|
|
|
|
|
@@ -110,7 +111,34 @@ IGL_INLINE Eigen::PlainObjectBase<Derivedobj> igl::project(
|
|
|
return win;
|
|
|
}
|
|
|
|
|
|
+#endif
|
|
|
+#endif
|
|
|
+
|
|
|
+Eigen::Vector3f igl::project(const Eigen::Vector3f& obj,
|
|
|
+ const Eigen::Matrix4f& model,
|
|
|
+ const Eigen::Matrix4f& proj,
|
|
|
+ const Eigen::Vector4f& viewport)
|
|
|
+{
|
|
|
+ Eigen::Vector4f tmp;
|
|
|
+ tmp << obj,1;
|
|
|
+
|
|
|
+ tmp = model * tmp;
|
|
|
+
|
|
|
+ tmp = proj * tmp;
|
|
|
+
|
|
|
+ tmp = tmp.array() / tmp(3);
|
|
|
+ tmp = tmp.array() * 0.5f + 0.5f;
|
|
|
+ tmp(0) = tmp(0) * viewport(2) + viewport(0);
|
|
|
+ tmp(1) = tmp(1) * viewport(3) + viewport(1);
|
|
|
+
|
|
|
+ return tmp.head(3);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
#ifdef IGL_STATIC_LIBRARY
|
|
|
+
|
|
|
+#ifndef IGL_NO_OPENGL
|
|
|
+#ifndef IGL_OPENGL_4
|
|
|
// Explicit template instanciations
|
|
|
template int igl::project<Eigen::Matrix<double, 3, 1, 0, 3, 1>, Eigen::Matrix<double, 3, 1, 0, 3, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >&);
|
|
|
template Eigen::PlainObjectBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> > igl::project<Eigen::Matrix<double, 3, 1, 0, 3, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> > const&);
|
|
@@ -119,5 +147,6 @@ template Eigen::PlainObjectBase<Eigen::Matrix<float, 3, 1, 0, 3, 1> > igl::proje
|
|
|
template Eigen::PlainObjectBase<Eigen::Matrix<double, 1, -1, 1, 1, -1> > igl::project<Eigen::Matrix<double, 1, -1, 1, 1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, 1, -1, 1, 1, -1> > const&);
|
|
|
template int igl::project<Eigen::Matrix<double, 1, 3, 1, 1, 3>, Eigen::Matrix<double, 1, 3, 1, 1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> >&);
|
|
|
#endif
|
|
|
+#endif
|
|
|
|
|
|
#endif
|