00001 /*-----------------------------------------------------------------------* 00002 Project: Nintendo Augmented Reality Library. 00003 File: narMesh.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 *-----------------------------------------------------------------------*/ 00020 #ifndef NAR_MESH_H__ 00021 #define NAR_MESH_H__ 00022 00023 #include "narPort.h" 00024 #include "narVec2.h" 00025 00026 namespace mw { namespace nar 00027 { 00028 class Image_cl; 00029 00033 enum MeshDiv_e 00034 { 00036 e_MeshDiv15 = 15, 00038 e_MeshDiv31 = 31, 00040 e_MeshDiv63 = 63 00041 }; 00042 00047 struct Color_st 00048 { 00049 s8 r,g,b; 00050 }; 00051 00054 class MeshColorData_ac 00055 { 00056 public: 00059 virtual const Color_st & 00060 GetColor( s32 t, s32 s ) const = 0; 00061 00064 virtual Color_st & 00065 GetColor( s32 t, s32 s ) = 0; 00066 }; 00067 00071 template< MeshDiv_e N > 00072 class MeshColorData_tc : public MeshColorData_ac 00073 { 00074 public: 00077 virtual const Color_st & 00078 GetColor( s32 t, s32 s ) const { return maa_Data[ t ][ s ]; } 00079 00082 virtual Color_st & 00083 GetColor( s32 t, s32 s ) { return maa_Data[ t ][ s ]; } 00084 protected: 00085 Color_st maa_Data[ N ][ N ]; 00086 s8 pad[ 5 ]; 00087 }; 00088 00091 class MeshVtxData_ac 00092 { 00093 public: 00096 virtual const Vec2F_st & 00097 GetVtx( s32 t, s32 s ) const = 0; 00098 00101 virtual Vec2F_st & 00102 GetVtx( s32 t, s32 s ) = 0; 00103 }; 00104 00108 template< MeshDiv_e N > 00109 class MeshVtxData_tc : public MeshVtxData_ac 00110 { 00111 public: 00114 virtual const Vec2F_st & 00115 GetVtx( s32 t, s32 s ) const { return maa_Data[ t ][ s ]; } 00116 00119 virtual Vec2F_st & 00120 GetVtx( s32 t, s32 s ) { return maa_Data[ t ][ s ]; } 00121 protected: 00122 Vec2F_st maa_Data[ N ][ N ]; 00123 }; 00124 00126 00129 class MeshStrictWork_ac 00130 { 00131 public: 00132 virtual Vec2F_st & 00133 getGrid( s32 nEdge, s32 nDiv ) = 0; 00134 00135 virtual const Vec2F_st & 00136 getGrid( s32 nEdge, s32 nDiv ) const = 0; 00137 00138 virtual Vec2F_st * 00139 getpGrid( s32 nEdge ) = 0; 00140 00141 virtual f32 00142 getST( s32 nST, s32 nDiv ) const = 0; 00143 00144 virtual f32 * 00145 getpST( s32 nST ) = 0; 00146 00147 virtual s32 00148 getDiv() const = 0; 00149 }; 00150 00154 template< s32 N > 00155 class MeshStrictWork_tc : public MeshStrictWork_ac 00156 { 00157 public: 00158 virtual Vec2F_st & 00159 getGrid( s32 nEdge, s32 nDiv ) { return maa_Grid[ nEdge ][ nDiv ]; } 00160 00161 virtual const Vec2F_st & 00162 getGrid( s32 nEdge, s32 nDiv ) const { return maa_Grid[ nEdge ][ nDiv ]; } 00163 00164 virtual Vec2F_st * 00165 getpGrid( s32 nEdge ) { return maa_Grid[ nEdge ]; } 00166 00167 virtual f32 00168 getST( s32 nST, s32 nDiv ) const { return maa_ST[ nST ][ nDiv ]; } 00169 00170 virtual f32 * 00171 getpST( s32 nST ) { return maa_ST[ nST ]; } 00172 00173 virtual s32 00174 getDiv() const { return N; } 00175 00176 private: 00177 Vec2F_st maa_Grid[ 4 ][ N + 2 ]; 00178 f32 maa_ST[ 2 ][ N + 2 ]; 00179 }; 00180 00183 class MeshStrict_cl 00184 { 00185 public: 00186 MeshStrict_cl( MeshStrictWork_ac & work ) : mr_Work( work ) 00187 {} 00188 00190 void precalc( const Vec2F_st * cap_Points ); 00191 00192 #if NAR_DEBUG__ 00193 00194 void drawInfo( const Image_cl & cr_Image, const Vec2F_st * cap_Points, bool isMarker ); 00195 #endif 00196 00197 void pickup( const Image_cl & cr_Image, MeshColorData_ac & r_MeshColor ); 00198 00200 void pickup( const Image_cl & cr_Image, MeshColorData_ac & r_MeshColor, MeshVtxData_ac & r_MeshVtx ); 00201 00203 void pickupFast( const Image_cl & cr_Image, MeshColorData_ac & r_MeshColor ); 00204 00206 void pickupFast( const Image_cl & cr_Image, MeshColorData_ac & r_MeshColor, MeshVtxData_ac & r_MeshVtx ); 00207 00209 s8 getOffset() const { return m_Offset; } 00210 private: 00211 Vec2F_st m_v10; 00212 Vec2F_st m_v30; 00213 Vec2F_st m_v21; 00214 Vec2F_st m_v23; 00215 MeshStrictWork_ac & mr_Work; 00216 s8 m_Offset; 00217 u8 pad1[ 3 ]; 00218 #if NAR_DEBUG__ 00219 bool m_isCalcVp; 00220 bool m_isDivEq; 00221 u8 pad2[ 2 ]; 00222 #endif 00223 void precalcVp( const Vec2F_st * cap_Points ); 00224 void precalcApprox( const Vec2F_st * cap_Points, const f32 * cap_L, const f32 * a_Cos ); 00225 }; 00227 } 00228 } 00229 #endif
© 2011-2012 Nintendo. All rights reserved.
CONFIDENTIAL