00001 /*-----------------------------------------------------------------------* 00002 Project: Nintendo Augmented Reality Library. 00003 File: narPlane.h 00004 00005 Copyright (C)2011-2012 Nintendo Co., Ltd. All rights reserved. 00006 00007 These coded instructions, statements, and computer programs contain 00008 proprietary information of Nintendo and/or its licensed developers 00009 and are protected by national and international copyright laws. They 00010 may not be disclosed to third parties or copied or duplicated in any 00011 form, in whole or in part, without the prior written consent of 00012 Nintendo. 00013 The content herein is highly confidential and should be handled 00014 accordingly. 00015 *-----------------------------------------------------------------------*/ 00016 00018 00022 #ifndef NAR_PLANE_H__ 00023 #define NAR_PLANE_H__ 00024 00025 #include "narVec3.h" 00026 00027 namespace mw { namespace nar 00028 { 00032 class Plane_cl 00033 { 00034 public: 00038 Plane_cl( const Vec3F_st & r_Normal, const Vec3F_st & r_Point ) 00039 { 00040 ma_Data[ me_A ] = r_Normal.X(); 00041 ma_Data[ me_B ] = r_Normal.Y(); 00042 ma_Data[ me_C ] = r_Normal.Z(); 00043 ma_Data[ me_D ] = - r_Normal.X() * r_Point.X() - r_Normal.Y() * r_Point.Y() - r_Normal.Z() * r_Point.Z(); 00044 } 00045 00046 f32 GetA() const { return ma_Data[ me_A ]; } 00047 f32 GetB() const { return ma_Data[ me_B ]; } 00048 f32 GetC() const { return ma_Data[ me_C ]; } 00049 f32 GetD() const { return ma_Data[ me_D ]; } 00050 00051 00056 void GetIntersection( Vec3F_st & r_Inter, const Vec3F_st & cr_Vec ) const 00057 { 00058 // Calculate straight-line parameter t 00059 f32 m = GetA() * cr_Vec.X() + GetB() * cr_Vec.Y() + GetC() * cr_Vec.Z(); 00060 f32 t = - GetD() / m; 00061 r_Inter = cr_Vec; 00062 r_Inter.Scale( t ); 00063 } 00064 private: 00065 enum 00066 { 00067 me_A, me_B, me_C, me_D, me_Max 00068 }; 00069 f32 ma_Data[ me_Max ]; 00070 }; 00071 } 00072 } 00073 #endif 00074
© 2011-2012 Nintendo. All rights reserved.
CONFIDENTIAL