00001 /*-----------------------------------------------------------------------* 00002 Project: Nintendo Augmented Reality Library. 00003 File: narMarker.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 *-----------------------------------------------------------------------*/ 00021 #ifndef NAR_MARKER_H__ 00022 #define NAR_MARKER_H__ 00023 00024 #include "narConfig.h" 00025 #include "narPort.h" 00026 #include "narVec2.h" 00027 #include "narVec3.h" 00028 #include "narProjection.h" 00029 #include "narTransformation.h" 00030 #include "narMarkerTemplate.h" 00031 #include "narDistortion.h" 00032 00033 namespace mw { namespace nar 00034 { 00035 class Distortion_cl; 00038 class Marker_cl 00039 { 00040 public: 00041 Marker_cl() :mcp_PatternVtxData( 0 ) 00042 {} 00043 00047 s32 GetID() const { return mcp_Template ?mcp_Template->id : -1; } 00048 00052 f32 GetScore() const { return m_Score; } 00053 00057 s32 GetDir() const { return m_Dir; } 00058 00061 Transformation_cl & GetrTransformation() { return m_Trans; } 00062 00065 bool IsEstimated() const { return m_Estimated; } 00066 00069 f32 GetSideLength() const 00070 { 00071 return mcp_Template ?mcp_Template->sideLength : 0 ; 00072 } 00073 00076 f32 GetAspectRatio() const 00077 { 00078 return mcp_Template ?mcp_Template->aspectRatio : 0 ; 00079 } 00080 00083 const Vec3F_st & GetrNormal() { return m_Trans.GetrYAxis(); } 00084 00089 void SuppressShake( f32 sim, f32 far ); 00090 00097 const PatternVtxData_cl * GetpPatternVtxData() 00098 { 00099 return mcp_PatternVtxData; 00100 } 00101 00103 00105 void Init( const MarkerTemplate_st * cp_Temp, 00106 const Vec2F_st * cap_Points, 00107 const PatternVtxData_cl * cp_PatternVtxData, 00108 s32 dir, 00109 f32 c_Score ); 00110 00111 00113 void SetEstimated( bool b ) { m_Estimated = b; } 00114 00115 const Vec2F_st * GetpDetectedVtx() const 00116 { 00117 return ma_VtxDetected; 00118 } 00119 00120 void SetDetectedVtx( s32 idx, f32 x, f32 y ) 00121 { 00122 ma_VtxDetected[ idx ].Set( x, y ); 00123 } 00124 00125 const Vec3F_st & GetrVtxOnRefPlane( s32 idx ) const 00126 { 00127 return ma_VtxOnRefPlane[ idx ]; 00128 } 00129 00130 Marker_cl * GetpPrev() { return mp_Prev; } 00131 void SetPrev( Marker_cl * p_Prev ) { mp_Prev = p_Prev; } 00132 Marker_cl * GetpNext() { return mp_Next; } 00133 void SetNext( Marker_cl * p_Next ) { mp_Next = p_Next; } 00134 00137 f32 GetSumOfEachVtxSquareDistance( const Marker_cl & cr ) const; 00138 00141 void AverageVtx( const Marker_cl & cr ); 00142 00145 void CalcVtxOnRefPlane( const Projection_cl & cr_Proj ) 00146 { 00147 for ( int vtx = 0; vtx < 4; vtx++ ) 00148 { 00149 cr_Proj.GetVtxOnReferencePlane( ma_VtxOnRefPlane[ vtx ], ma_VtxDetected[ vtx ] ); 00150 } 00151 } 00152 00155 void CalcVtxOnRefPlane( const Projection_cl & cr_Proj, const Distortion_cl & cr_Dist ) 00156 { 00157 for ( int vtx = 0; vtx < 4; vtx++ ) 00158 { 00159 Vec2F_st ideal; 00160 cr_Dist.GetIdealFromObserv( ideal, ma_VtxDetected[ vtx ] ); 00161 cr_Proj.GetVtxOnReferencePlane( ma_VtxOnRefPlane[ vtx ], ideal ); 00162 } 00163 } 00164 00167 f32 EvaluateMatrix() const; 00168 00175 f32 AdjustRotate( f32 targetErr, s32 maxCnt ); 00176 00179 Vec3F_st & GetrYAxisMove() { return m_YAxisMove; } 00180 00182 void SetYAxisMoveRec( bool b ) { m_YAxisMoveRec = b; } 00183 00187 bool IsSimilarYAxisRotate(); 00188 00189 f32 GetInterpolationCoefficient() const { return m_InterpolationCoefficient; } 00190 void SetInterpolationCoefficient( f32 t ) { m_InterpolationCoefficient = t; } 00191 00193 f32 GetSqareDistanceQuadMid( const Vec2F_st * cap_Points ); 00195 f32 GetSqareDistanceQuadMid( const Marker_cl & cr ) 00196 { 00197 return GetSqareDistanceQuadMid( cr.ma_VtxDetected ); 00198 } 00199 00201 static f32 GetDoubleArea( const Vec2F_st * cap_Points ); 00203 f32 GetDoubleArea() 00204 { 00205 return GetDoubleArea( ma_VtxDetected ); 00206 } 00207 00209 bool IsOverlapped( const Vec2F_st * cap_Points ) 00210 { 00211 return GetDoubleArea( cap_Points ) * 2.f > GetSqareDistanceQuadMid( cap_Points ); 00212 } 00213 00215 void SetInterpolated( bool b ) { m_Interpolated = b; } 00216 00218 private: 00221 Vec2F_st ma_VtxDetected[ 4 ]; 00223 Vec3F_st ma_VtxOnRefPlane[ 4 ]; 00225 f32 m_Score; 00227 s32 m_Dir; 00229 const MarkerTemplate_st * mcp_Template; 00231 Transformation_cl m_Trans; 00232 00234 Marker_cl * mp_Prev; 00235 Marker_cl * mp_Next; 00236 00238 bool m_Estimated; 00239 00241 bool m_YAxisMoveRec; 00242 00243 bool m_Interpolated; 00244 00245 u8 pad; 00246 00248 f32 m_InterpolationCoefficient; 00249 00251 Vec3F_st m_YAxisMove; 00252 00254 const PatternVtxData_cl * mcp_PatternVtxData; 00255 }; 00256 } 00257 } 00258 00259 #endif
© 2011-2012 Nintendo. All rights reserved.
CONFIDENTIAL