• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

PolyVoxCore/include/PolyVoxCore/Raycast.h

Go to the documentation of this file.
00001 /*******************************************************************************
00002 Copyright (c) 2005-2009 David Williams
00003 
00004 This software is provided 'as-is', without any express or implied
00005 warranty. In no event will the authors be held liable for any damages
00006 arising from the use of this software.
00007 
00008 Permission is granted to anyone to use this software for any purpose,
00009 including commercial applications, and to alter it and redistribute it
00010 freely, subject to the following restrictions:
00011 
00012     1. The origin of this software must not be misrepresented; you must not
00013     claim that you wrote the original software. If you use this software
00014     in a product, an acknowledgment in the product documentation would be
00015     appreciated but is not required.
00016 
00017     2. Altered source versions must be plainly marked as such, and must not be
00018     misrepresented as being the original software.
00019 
00020     3. This notice may not be removed or altered from any source
00021     distribution.
00022 *******************************************************************************/
00023 
00024 #ifndef __PolyVox_Raycast_H__
00025 #define __PolyVox_Raycast_H__
00026 
00027 #include "PolyVoxCore/Vector.h"
00028 
00029 namespace PolyVox
00030 {
00038     struct RaycastResult
00039     {
00041         bool foundIntersection;
00043         Vector3DInt32 intersectionVoxel;
00044         Vector3DInt32 previousVoxel;
00045     };
00046 
00086     template< template<typename> class VolumeType, typename VoxelType>
00087     class Raycast
00088     {
00089     public:
00091         Raycast(VolumeType<VoxelType>* volData, const Vector3DFloat& v3dStart, const Vector3DFloat& v3dDirection, RaycastResult& result);
00092 
00094         void setStart(const Vector3DFloat& v3dStart);
00096         void setDirection(const Vector3DFloat& v3dDirection);
00097 
00099         void execute();
00100 
00101     private:
00102         RaycastResult& m_result;
00103 
00104         void doRaycast(float x1, float y1, float z1, float x2, float y2, float z2);
00105 
00106         VolumeType<VoxelType>* m_volData;
00107         typename VolumeType<VoxelType>::Sampler m_sampVolume;
00108 
00109         Vector3DFloat m_v3dStart;
00110         Vector3DFloat m_v3dDirection;
00111         float m_fMaxDistance;
00112     };
00113 }
00114 
00115 #include "PolyVoxCore/Raycast.inl"
00116 
00117 #endif //__PolyVox_Raycast_H__

Generated on Sat Nov 19 2011 00:27:30 for PolyVox by  doxygen 1.7.1