00001 // Copyright (c) 1998-2014 by Tech Soft 3D, Inc. 00002 // 00003 // The information contained herein is confidential and proprietary to Tech Soft 3D, Inc., 00004 // and considered a trade secret as defined under civil and criminal statutes. 00005 // Tech Soft 3D, Inc. shall pursue its civil and criminal remedies in the event of 00006 // unauthorized use or misappropriation of its trade secrets. Use of this information 00007 // by anyone other than authorized employees of Tech Soft 3D, Inc. is granted only under 00008 // a written non-disclosure agreement, expressly prescribing the scope and manner of such use. 00009 00010 #ifndef _HDWFSTREAM_H 00011 #define _HDWFSTREAM_H 00012 00013 #include "hc.h" 00014 #include "HStream.h" 00015 00016 00017 class HW3DPoint 00018 { 00019 public: 00020 float x; 00021 float y; 00022 float z; 00023 00025 HW3DPoint() : x(0), y(0), z(0) {} 00027 HW3DPoint(float X, float Y, float Z=0.0f) : x(X), y(Y), z(Z) {} 00029 HW3DPoint(HW3DPoint const *p) { x = p->x; y = p->y; z = p->z;}; 00031 HW3DPoint(const HW3DPoint & p) { x = p.x; y = p.y; z = p.z; }; 00032 00034 void Set(float X,float Y,float Z = 0.0f) { x = X; y = Y; z = Z; }; 00036 void Set(HW3DPoint * p) { x = p->x; y = p->y; z = p->z; }; 00038 void Set(HW3DPoint const * p) { x = p->x; y = p->y; z = p->z; }; 00040 void Set(HW3DPoint & p) { x = p.x; y = p.y; z = p.z; }; 00042 void Set(const HW3DPoint & p) { x = p.x; y = p.y; z = p.z; }; 00043 }; 00044 00045 class HW3DCamera { 00046 public: 00047 bool is_valid; 00048 HW3DPoint position; 00049 HW3DPoint target; 00050 HW3DPoint up_vector; 00051 float field_width; 00052 float field_height; 00053 char projection[128]; 00054 }; 00055 00056 class HW3DStream_Initial_View : public HTK_Camera 00057 { 00058 public: 00059 HW3DStream_Initial_View(HW3DCamera * initial_view) : HTK_Camera(TKE_View), m_pInitialCamera(initial_view) {;} 00060 00061 TK_Status Interpret(BStreamFileToolkit & /*tk*/, ID_Key /*key*/, int /*variant*/) 00062 { 00063 if(!m_pInitialCamera) 00064 return TK_Normal; 00065 00066 m_settings[0] = m_pInitialCamera->position.x; 00067 m_settings[1] = m_pInitialCamera->position.y; 00068 m_settings[2] = m_pInitialCamera->position.z; 00069 00070 m_settings[3] = m_pInitialCamera->target.x; 00071 m_settings[4] = m_pInitialCamera->target.y; 00072 m_settings[5] = m_pInitialCamera->target.z; 00073 00074 m_settings[6] = m_pInitialCamera->up_vector.x; 00075 m_settings[7] = m_pInitialCamera->up_vector.y; 00076 m_settings[8] = m_pInitialCamera->up_vector.z; 00077 00078 m_settings[9] = m_pInitialCamera->field_width; 00079 m_settings[10] = m_pInitialCamera->field_height; 00080 00081 if(m_pInitialCamera->projection[0] == 'p') 00082 m_projection = TKO_Camera_Perspective; 00083 else 00084 m_projection = TKO_Camera_Orthographic; 00085 00086 SetView("default"); 00087 00088 return TK_Normal; 00089 } 00090 00091 00092 TK_Status Execute(BStreamFileToolkit & /*tk*/) alter 00093 { 00094 TK_Status status=TK_Normal; 00095 00096 if (!strcmp(GetView(),"default")) 00097 { 00098 m_pInitialCamera->is_valid = true; 00099 00100 m_pInitialCamera->position.Set(m_settings[0],m_settings[1],m_settings[2]); 00101 m_pInitialCamera->target.Set(m_settings[3],m_settings[4],m_settings[5]); 00102 m_pInitialCamera->up_vector.Set(m_settings[6],m_settings[7],m_settings[8]); 00103 m_pInitialCamera->field_width = m_settings[9]; 00104 m_pInitialCamera->field_height = m_settings[10]; 00105 00106 switch ((int) m_projection) { 00107 00108 case TKO_Camera_Orthographic: 00109 strcpy_s (m_pInitialCamera->projection, "orthographic"); 00110 break; 00111 00112 case TKO_Camera_Perspective: 00113 strcpy_s (m_pInitialCamera->projection, "perspective"); 00114 break; 00115 00116 default: 00117 strcpy_s (m_pInitialCamera->projection, "stretched"); 00118 break; 00119 } 00120 00121 } 00122 00123 return (status); 00124 }; 00125 00126 private: 00127 HW3DCamera * m_pInitialCamera; 00128 00129 }; 00130 #if 0 00131 // Translate all the TKE_Image's to W3DE_Image 00132 class HW3DStream_Image_Converter : public HTK_Image 00133 { 00134 private: 00135 HW3DStream_Image_Converter(const HW3DStream_Image_Converter&); 00136 HW3DStream_Image_Converter& operator=(const HW3DStream_Image_Converter&); 00137 00138 public: 00139 00140 HW3DStream_Image_Converter () 00141 { 00142 m_opcode = W3DE_Image; 00143 m_size[0] = m_size[1] = 0; 00144 } 00145 00146 ~HW3DStream_Image_Converter() 00147 { 00148 delete [] m_name; 00149 } 00150 00151 TK_Status Write (BStreamFileToolkit & tk) alter 00152 { 00153 TK_Status status = TK_Normal; 00154 00155 switch (m_stage) { 00156 case 0: { 00157 if ((status = PutOpcode (tk)) != TK_Normal) 00158 return status; 00159 m_stage++; 00160 } 00161 00162 case 1: { 00163 00164 if (m_name_length > 0) { 00165 unsigned char byte = (unsigned char)m_name_length; 00166 // need handling for string > 255 ? 00167 if ((status = PutData (tk, byte)) != TK_Normal) 00168 return status; 00169 } 00170 m_stage++; 00171 } 00172 00173 case 2: { 00174 if (m_name_length > 0) { 00175 if ((status = PutData (tk, m_name, m_name_length)) != TK_Normal) 00176 return status; 00177 } 00178 m_stage++; 00179 } 00180 case 3: 00181 { 00182 if ((status = PutData(tk, m_size[0])) != TK_Normal) 00183 return status; 00184 if ((status = PutData(tk, m_size[1])) != TK_Normal) 00185 return status; 00186 if ((status = PutData(tk, 24)) != TK_Normal) 00187 return status; 00188 m_stage++; 00189 00190 } 00191 00192 case 4: { 00193 if (Tagging (tk)) 00194 status = Tag (tk); 00195 00196 m_stage = -1; 00197 } break; 00198 00199 default: 00200 return tk.Error(); 00201 } 00202 00203 return status; 00204 } 00205 }; 00206 #endif 00207 00208 bool HW3D_Read_W3D_File(DWFInputStream * input_stream, 00209 void * pModelSection, 00210 HW3DCamera * ret_initial_camera, 00211 bool importMetaData); 00212 00213 00214 bool generate_object_definitions(std::map<HC_KEY, int> const & tk_map, 00215 HC_KEY key, 00216 void * arg1, 00217 void * arg2 00218 ); 00219 #define W3D_READ_BUFFER_SIZE 16*1024 00220 00221 #endif // _HDWFSTREAM_H 00222 00223