[Liblas-commits] hg-main-tree: add FreeGLUT library
liblas-commits at liblas.org
liblas-commits at liblas.org
Tue Apr 5 18:10:20 EDT 2011
details: http://hg.libpc.orghg-main-tree/rev/fb0acbbc0e2a
changeset: 500:fb0acbbc0e2a
user: Michael P. Gerlek <mpg at flaxen.com>
date: Tue Apr 05 14:02:08 2011 -0700
description:
add FreeGLUT library
Subject: hg-main-tree: add pcview
details: http://hg.libpc.orghg-main-tree/rev/3f32b2fe089d
changeset: 501:3f32b2fe089d
user: Michael P. Gerlek <mpg at flaxen.com>
date: Tue Apr 05 14:28:51 2011 -0700
description:
add pcview
Subject: hg-main-tree: add las reading
details: http://hg.libpc.orghg-main-tree/rev/0632d96ddacc
changeset: 502:0632d96ddacc
user: Michael P. Gerlek <mpg at flaxen.com>
date: Tue Apr 05 15:09:55 2011 -0700
description:
add las reading
Subject: hg-main-tree: merge
details: http://hg.libpc.orghg-main-tree/rev/8f814eb3342f
changeset: 503:8f814eb3342f
user: Michael P. Gerlek <mpg at flaxen.com>
date: Tue Apr 05 15:10:07 2011 -0700
description:
merge
diffstat:
CMakeLists.txt | 9 +
apps/CMakeLists.txt | 7 +-
apps/pc2pc.cpp | 2 +-
apps/pcview/ArcBall.cpp | 252 +
apps/pcview/ArcBall.hpp | 72 +
apps/pcview/ArcBallMath.cpp | 300 +
apps/pcview/ArcBallMath.hpp | 197 +
apps/pcview/CMakeLists.txt | 81 +
apps/pcview/Commands.cpp | 35 +
apps/pcview/Commands.hpp | 93 +
apps/pcview/Controller.cpp | 220 +
apps/pcview/Controller.hpp | 108 +
apps/pcview/Engine.cpp | 536 +
apps/pcview/Engine.hpp | 87 +
apps/pcview/glext.h | 11049 ++++++++++++++++++++++++++++++
apps/pcview/main.cpp | 189 +
cmake/modules/FindFreeGLUT.cmake | 37 +
include/libpc/drivers/oci/oci_wrapper.h | 1 +
mpg-config.bat | 8 +
src/drivers/oci/Iterator.cpp | 3 +
src/drivers/oci/oci_wrapper.cpp | 14 +
21 files changed, 13298 insertions(+), 2 deletions(-)
diffs (truncated from 13440 to 300 lines):
diff -r fbd1fc6c4e6e -r 8f814eb3342f CMakeLists.txt
--- a/CMakeLists.txt Tue Apr 05 12:00:00 2011 -0500
+++ b/CMakeLists.txt Tue Apr 05 15:10:07 2011 -0700
@@ -362,6 +362,15 @@
endif()
endif()
+if(WITH_FREEGLUT)
+ find_package(FreeGLUT)
+ if(FREEGLUT_FOUND)
+ include_directories(${FREEGLUT_INCLUDE_DIR})
+ add_definitions(-DHAVE_FREEGLUT=1)
+ set(LIBPC_HAVE_FREEGLUT 1)
+ message(STATUS "Found FreeGLUT")
+ endif()
+endif()
#------------------------------------------------------------------------------
# installation path settings
diff -r fbd1fc6c4e6e -r 8f814eb3342f apps/CMakeLists.txt
--- a/apps/CMakeLists.txt Tue Apr 05 12:00:00 2011 -0500
+++ b/apps/CMakeLists.txt Tue Apr 05 15:10:07 2011 -0700
@@ -4,6 +4,11 @@
# (based originally on the libLAS files copyright Mateusz Loskot)
+if(FREEGLUT_FOUND)
+ subdirs(pcview)
+ endif()
+
+
#------------------------------------------------------------------------------
# includes
#------------------------------------------------------------------------------
@@ -21,7 +26,7 @@
set(LIBPC_UTILITIES
- ${PCINFO} ${PC2PC})
+ ${PCINFO} ${PC2PC} ${PCVIEW})
#------------------------------------------------------------------------------
diff -r fbd1fc6c4e6e -r 8f814eb3342f apps/pc2pc.cpp
--- a/apps/pc2pc.cpp Tue Apr 05 12:00:00 2011 -0500
+++ b/apps/pc2pc.cpp Tue Apr 05 15:10:07 2011 -0700
@@ -131,7 +131,7 @@
libpc::drivers::oci::Options options;
boost::property_tree::ptree& tree = options.GetPTree();
- boost::uint32_t capacity = 10000;
+ boost::uint32_t capacity = 12;
tree.put("capacity", capacity);
tree.put("connection", "lidar/lidar at 192.168.56.101/orcl");
// tree.put("connection", "lidar/lidar at oracle.hobu.biz/crrel");
diff -r fbd1fc6c4e6e -r 8f814eb3342f apps/pcview/ArcBall.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/apps/pcview/ArcBall.cpp Tue Apr 05 15:10:07 2011 -0700
@@ -0,0 +1,252 @@
+//
+// This code is derived from the well-known, much-copied Arcball class:
+// (C) 1999-2003 Tatewake.com
+// This code is provided under the license terms from the http://nehe.gamedev.net/
+// tutorials/basecode series, which (depending on where you look) is either CC-SA or
+// the following:
+//
+// If you plan to put this program on your web page or a cdrom of
+// any sort, let me know via email, I'm curious to see where
+// it ends up :)
+// If you use the code for your own projects please give me credit,
+// or mention my web site somewhere in your program or it's docs.
+//
+// http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=48
+//
+
+#include <libpc/libpc.hpp>
+
+#ifdef LIBPC_COMPILER_MSVC
+#include <windows.h>
+#endif
+
+#include <gl/gl.h>
+#include <gl/glu.h>
+
+#include <cmath>
+#include <cassert>
+
+#include "ArcBall.hpp"
+
+
+//-----------------------------------------------------------------------------
+// ArcBallControl
+//-----------------------------------------------------------------------------
+
+
+ArcBall::ArcBall(GLfloat NewWidth, GLfloat NewHeight)
+{
+ //Clear initial values
+ this->StVec.s.X =
+ this->StVec.s.Y =
+ this->StVec.s.Z =
+
+ this->EnVec.s.X =
+ this->EnVec.s.Y =
+ this->EnVec.s.Z = 0.0f;
+
+ //Set initial bounds
+ this->setBounds(NewWidth, NewHeight);
+}
+
+
+void ArcBall::setBounds(GLfloat NewWidth, GLfloat NewHeight)
+{
+ assert((NewWidth > 1.0f) && (NewHeight > 1.0f));
+
+ //Set adjustment factor for width/height
+ this->AdjustWidth = 1.0f / ((NewWidth - 1.0f) * 0.5f);
+ this->AdjustHeight = 1.0f / ((NewHeight - 1.0f) * 0.5f);
+}
+
+
+//Arcball sphere constants:
+//Diameter is 2.0f
+//Radius is 1.0f
+//Radius squared is 1.0f
+
+void ArcBall::_mapToSphere(const Point2fT* NewPt, Vector3fT* NewVec) const
+{
+ Point2fT TempPt;
+ GLfloat length;
+
+ //Copy paramter into temp point
+ TempPt = *NewPt;
+
+ //Adjust point coords and scale down to range of [-1 ... 1]
+ TempPt.s.X = (TempPt.s.X * this->AdjustWidth) - 1.0f;
+ TempPt.s.Y = 1.0f - (TempPt.s.Y * this->AdjustHeight);
+
+ //Compute the square of the length of the vector to the point from the center
+ length = (TempPt.s.X * TempPt.s.X) + (TempPt.s.Y * TempPt.s.Y);
+
+ //If the point is mapped outside of the sphere... (length > radius squared)
+ if (length > 1.0f)
+ {
+ GLfloat norm;
+
+ //Compute a normalizing factor (radius / sqrt(length))
+ norm = 1.0f / sqrtf(length);
+
+ //Return the "normalized" vector, a point on the sphere
+ NewVec->s.X = TempPt.s.X * norm;
+ NewVec->s.Y = TempPt.s.Y * norm;
+ NewVec->s.Z = 0.0f;
+ }
+ else //Else it's on the inside
+ {
+ //Return a vector to a point mapped inside the sphere sqrt(radius squared - length)
+ NewVec->s.X = TempPt.s.X;
+ NewVec->s.Y = TempPt.s.Y;
+ NewVec->s.Z = sqrtf(1.0f - length);
+ }
+}
+
+
+void ArcBall::click(const Point2fT* NewPt)
+{
+ //Map the point to the sphere
+ this->_mapToSphere(NewPt, &this->StVec);
+}
+
+
+void ArcBall::drag(const Point2fT* NewPt, Quat4fT* NewRot)
+{
+ //Map the point to the sphere
+ this->_mapToSphere(NewPt, &this->EnVec);
+
+ //Return the quaternion equivalent to the rotation
+ if (NewRot)
+ {
+ Vector3fT Perp;
+
+ //Compute the vector perpendicular to the begin and end vectors
+ Vector3fCross(&Perp, &this->StVec, &this->EnVec);
+
+ //Compute the length of the perpendicular vector
+ if (Vector3fLength(&Perp) > Epsilon) //if its non-zero
+ {
+ //We're ok, so return the perpendicular vector as the transform after all
+ NewRot->s.X = Perp.s.X;
+ NewRot->s.Y = Perp.s.Y;
+ NewRot->s.Z = Perp.s.Z;
+ //In the quaternion values, w is cosine (theta / 2), where theta is rotation angle
+ NewRot->s.W= Vector3fDot(&this->StVec, &this->EnVec);
+ }
+ else //if its zero
+ {
+ //The begin and end vectors coincide, so return an identity transform
+ NewRot->s.X =
+ NewRot->s.Y =
+ NewRot->s.Z =
+ NewRot->s.W = 0.0f;
+ }
+ }
+}
+
+
+//-----------------------------------------------------------------------------
+// ArcBallControl
+//-----------------------------------------------------------------------------
+
+
+ArcBallControl::ArcBallControl(int width, int height)
+ : ArcBall((GLfloat)width, (GLfloat)height)
+ , m_isClicked(false)
+ , m_isDragging(false)
+{
+ reset();
+ return;
+}
+
+
+ArcBallControl::~ArcBallControl()
+{
+ return;
+}
+
+void ArcBallControl::reset()
+{
+ ArcBall::Matrix3fSetIdentity(&m_lastRot);
+ ArcBall::Matrix3fSetIdentity(&m_thisRot);
+ ArcBall::Matrix4fSetIdentity(&m_transform);
+
+ ArcBall::Matrix4fSetRotationFromMatrix3f(&m_transform, &m_thisRot);
+}
+
+
+// returns true if an update is needed
+bool ArcBallControl::update(int x, int y)
+{
+ if (!m_isDragging)
+ {
+ return false;
+ }
+
+ if (!m_isClicked)
+ {
+ m_isDragging = false;
+ return false;
+ }
+
+ // still clicked, still dragging
+ m_mousePt.s.X = (GLfloat)x;
+ m_mousePt.s.Y = (GLfloat)y;
+
+ dragAction();
+
+ return true;
+}
+
+
+void ArcBallControl::dragAction()
+{
+ ArcBall::Quat4fT thisQuat;
+
+ this->drag(&m_mousePt, &thisQuat); // Update End Vector And Get Rotation As Quaternion
+ ArcBall::Matrix3fSetRotationFromQuat4f(&m_thisRot, &thisQuat); // Convert Quaternion Into Matrix3fT
+ ArcBall::Matrix3fMulMatrix3f(&m_thisRot, &m_lastRot); // Accumulate Last Rotation Into This One
+ ArcBall::Matrix4fSetRotationFromMatrix3f(&m_transform, &m_thisRot); // Set Our Final Transform's Rotation From This One
+
+ return;
+}
+
+
+bool ArcBallControl::changeState(bool isClicked, int mx, int my)
+{
+ m_isClicked = isClicked;
+
+ m_mousePt.s.X = (GLfloat)mx;
+ m_mousePt.s.Y = (GLfloat)my;
+
+ if (!m_isDragging)
+ {
+ if (!m_isClicked)
+ {
+ return false;
+ }
+
+ // first click
+ m_isDragging = true; // Prepare For Dragging
+ m_lastRot = m_thisRot; // Set Last Static Rotation To Last Dynamic One
+ this->click(&m_mousePt); // Update Start Vector And Prepare For Dragging
+ return false;
+ }
+
+ // we are dragging
+ if (!m_isClicked)
+ {
+ // no longer dragging
+ m_isDragging = false;
+ return false;
More information about the Liblas-commits
mailing list