#include "basetype.h"#include "xform3d.h"#include "body.h"#include "XFArray.h"#include "camera.h"Go to the source code of this file.
Compounds | |
| struct | geBodyInst_Geometry |
| struct | geBodyInst_SkinVertex |
Typedefs | |
| typedef geBodyInst | geBodyInst |
| typedef int16 | geBodyInst_Index |
| typedef geBodyInst_SkinVertex | geBodyInst_SkinVertex |
| typedef geBodyInst_Geometry | geBodyInst_Geometry |
Enumerations | |
| enum | geBodyInst_FaceType { GE_BODYINST_FACE_TRIANGLE, GE_BODYINST_FACE_TRISTRIP, GE_BODYINST_FACE_TRIFAN } |
Functions | |
| geBodyInst *GENESISCC | geBodyInst_Create (const geBody *B) |
| void GENESISCC | geBodyInst_Destroy (geBodyInst **BI) |
| const geBodyInst_Geometry *GENESISCC | geBodyInst_GetGeometry (const geBodyInst *BI, const geVec3d *Scale, const geXFArray *BoneXformArray, int LevelOfDetail, const geCamera *Camera) |
|
|
Definition at line 47 of file bodyinst.h. |
|
|
|
|
|
Definition at line 49 of file bodyinst.h. Referenced by gePuppet_DrawShadow(), gePuppet_Render(), and gePuppet_RenderThroughFrustum(). |
|
|
|
|
|
Definition at line 51 of file bodyinst.h.
00052 {
00053 GE_BODYINST_FACE_TRIANGLE,
00054 GE_BODYINST_FACE_TRISTRIP,
00055 GE_BODYINST_FACE_TRIFAN
00056 } geBodyInst_FaceType;
|
|
|
Definition at line 59 of file bodyinst.c. References B, geBodyInst::BodyTemplate, ERR_BODY_ENOMEM, geBodyInst::ExportGeometry, geBodyInst::FaceCount, G, GE_FALSE, GE_RAM_ALLOCATE_STRUCT, geBody_Index, geBody_IsValid(), geErrorLog_Add, GENESISCC, geBodyInst::LastLevelOfDetail, and NULL. Referenced by gePuppet_Create().
00060 {
00061 geBodyInst *BI;
00062 assert( B != NULL );
00063 assert( geBody_IsValid(B) != GE_FALSE );
00064
00065 BI = GE_RAM_ALLOCATE_STRUCT(geBodyInst);
00066 if (BI == NULL)
00067 {
00068 geErrorLog_Add(ERR_BODY_ENOMEM, NULL);
00069 return NULL;
00070 }
00071 BI->BodyTemplate = B;
00072 {
00073 geBodyInst_Geometry *G = &(BI->ExportGeometry);
00074 G->SkinVertexCount =0;
00075 G->SkinVertexArray = NULL;
00076
00077 G->NormalCount = 0;
00078 G->NormalArray = NULL;
00079
00080 G->FaceCount = (geBody_Index) 0;
00081 G->FaceListSize = 0;
00082 G->FaceList = NULL;
00083 }
00084
00085 BI->LastLevelOfDetail = -1;
00086 BI->FaceCount = 0;
00087
00088 return BI;
00089 }
|
|
|
Definition at line 92 of file bodyinst.c. References G, GENESISCC, geRam_Free, and NULL. Referenced by gePuppet_Destroy().
00093 {
00094 geBodyInst_Geometry *G;
00095 assert( BI != NULL );
00096 assert( *BI != NULL );
00097 G = &( (*BI)->ExportGeometry );
00098 if (G->SkinVertexArray != NULL )
00099 {
00100 geRam_Free( G->SkinVertexArray );
00101 G->SkinVertexArray = NULL;
00102 }
00103 if (G->NormalArray != NULL )
00104 {
00105 geRam_Free( G->NormalArray );
00106 G->NormalArray = NULL;
00107 }
00108 if (G->FaceList != NULL )
00109 {
00110 geRam_Free( G->FaceList );
00111 G->FaceList = NULL;
00112 }
00113 geRam_Free( *BI );
00114 *BI = NULL;
00115 }
|
|
||||||||||||||||||||||||
|
Definition at line 190 of file bodyinst.c. References B, geBodyInst::BodyTemplate, geBody_Normal::BoneIndex, geBody_XSkinVertex::BoneIndex, ERR_BODY_BONEXFARRAY, G, GE_BODY_REALLY_BIG_NUMBER, GE_BODYINST_FACE_TRIANGLE, GE_FALSE, geBody_Index, geBody_IsValid(), geBodyInst_GetGeometryPrep(), geBodyInst_PostScale(), geBoolean, geCamera_GetCameraSpaceXForm(), geCamera_Project(), geCamera_ProjectZ(), geErrorLog_Add, GENESISCC, geVec3d_Set(), geXFArray_GetElements(), geXForm3d_Multiply(), geXForm3d_Rotate(), geXForm3d_Transform(), geBodyInst::LastLevelOfDetail, geBody_Normal::LevelOfDetailMask, geBody_XSkinVertex::LevelOfDetailMask, geBody_Normal::Normal, NULL, geBodyInst_SkinVertex::ReferenceBoneIndex, geBodyInst_SkinVertex::SVPoint, geBodyInst_SkinVertex::SVU, geBodyInst_SkinVertex::SVV, uint32, geVec3d::X, geBody_XSkinVertex::XPoint, geBody_XSkinVertex::XU, geBody_XSkinVertex::XV, geVec3d::Y, and geVec3d::Z. Referenced by gePuppet_Render(), and gePuppet_RenderThroughFrustum().
00196 {
00197 geBodyInst_Geometry *G;
00198 const geBody *B;
00199 geXForm3d *BoneXFArray;
00200 int BoneXFCount;
00201 geBody_Index BoneIndex;
00202
00203 geBoolean GottaUpdateFaces = GE_FALSE;
00204 assert( BI != NULL );
00205 assert( BoneTransformArray != NULL );
00206 assert( geBody_IsValid(BI->BodyTemplate) != GE_FALSE );
00207
00208 G = geBodyInst_GetGeometryPrep((geBodyInst *)BI,LevelOfDetail);
00209 if (G == NULL)
00210 {
00211 return NULL;
00212 }
00213
00214
00215 B = BI->BodyTemplate;
00216
00217 BoneXFArray = geXFArray_GetElements(BoneTransformArray,&BoneXFCount);
00218 if ( BoneXFArray == NULL)
00219 {
00220 geErrorLog_Add(ERR_BODY_BONEXFARRAY, NULL);
00221 return NULL;
00222 }
00223 if (BoneXFCount != B->BoneCount)
00224 {
00225 geErrorLog_Add(ERR_BODY_BONEXFARRAY, NULL);
00226 return NULL;
00227 }
00228
00229
00230 {
00231 int i,LevelOfDetailBit;
00232
00233 if (Camera != NULL)
00234 {
00235 // transform and project all appropriate points
00236 geBody_XSkinVertex *S;
00237 geBodyInst_SkinVertex *D;
00238 LevelOfDetailBit = 1 << LevelOfDetail;
00239 BoneIndex = -1; // S->BoneIndex won't ever be this.
00240 geVec3d_Set(&(G->Maxs), -GE_BODY_REALLY_BIG_NUMBER, -GE_BODY_REALLY_BIG_NUMBER, -GE_BODY_REALLY_BIG_NUMBER );
00241 geVec3d_Set(&(G->Mins), GE_BODY_REALLY_BIG_NUMBER, GE_BODY_REALLY_BIG_NUMBER, GE_BODY_REALLY_BIG_NUMBER );
00242 for (i=B->XSkinVertexCount,S=B->XSkinVertexArray,D=G->SkinVertexArray;
00243 i>0;
00244 i--,S++,D++)
00245 {
00246 geXForm3d ObjectToCamera;
00247 if (S->BoneIndex!=BoneIndex)
00248 { //Keep XSkinVertexArray sorted by BoneIndex for best performance
00249 BoneIndex = S->BoneIndex;
00250 geXForm3d_Multiply( geCamera_GetCameraSpaceXForm(Camera),
00251 &(BoneXFArray[BoneIndex]),
00252 &ObjectToCamera);
00253 geBodyInst_PostScale(&ObjectToCamera,ScaleVector,&ObjectToCamera);
00254 }
00255 if ( S->LevelOfDetailMask && LevelOfDetailBit )
00256 {
00257 geVec3d *VecDestPtr = &(D->SVPoint);
00258 geXForm3d_Transform( &(ObjectToCamera),
00259 &(S->XPoint),VecDestPtr);
00260 #ifdef ONE_OVER_Z_PIPELINE
00261 geCamera_ProjectZ( Camera, VecDestPtr, VecDestPtr);
00262 #else
00263 geCamera_Project( Camera, VecDestPtr, VecDestPtr);
00264 #endif
00265 D->SVU = S->XU;
00266 D->SVV = S->XV;
00267 if (VecDestPtr->X > G->Maxs.X ) G->Maxs.X = VecDestPtr->X;
00268 if (VecDestPtr->X < G->Mins.X ) G->Mins.X = VecDestPtr->X;
00269 if (VecDestPtr->Y > G->Maxs.Y ) G->Maxs.Y = VecDestPtr->Y;
00270 if (VecDestPtr->Y < G->Mins.Y ) G->Mins.Y = VecDestPtr->Y;
00271 if (VecDestPtr->Z > G->Maxs.Z ) G->Maxs.Z = VecDestPtr->Z;
00272 if (VecDestPtr->Z < G->Mins.Z ) G->Mins.Z = VecDestPtr->Z;
00273 D->ReferenceBoneIndex=BoneIndex;
00274 }
00275 }
00276 }
00277 else
00278 {
00279 // transform all appropriate points
00280 geBody_XSkinVertex *S;
00281 geBodyInst_SkinVertex *D;
00282 LevelOfDetailBit = 1 << LevelOfDetail;
00283 BoneIndex = -1; // S->BoneIndex won't ever be this.
00284 geVec3d_Set(&(G->Maxs), -GE_BODY_REALLY_BIG_NUMBER, -GE_BODY_REALLY_BIG_NUMBER, -GE_BODY_REALLY_BIG_NUMBER );
00285 geVec3d_Set(&(G->Mins), GE_BODY_REALLY_BIG_NUMBER, GE_BODY_REALLY_BIG_NUMBER, GE_BODY_REALLY_BIG_NUMBER );
00286
00287 for (i=B->XSkinVertexCount,S=B->XSkinVertexArray,D=G->SkinVertexArray;
00288 i>0;
00289 i--,S++,D++)
00290 {
00291 geXForm3d ObjectToWorld;
00292 if (S->BoneIndex!=BoneIndex)
00293 { //Keep XSkinVertexArray sorted by BoneIndex for best performance
00294 BoneIndex = S->BoneIndex;
00295 geBodyInst_PostScale(&BoneXFArray[BoneIndex],ScaleVector,&ObjectToWorld);
00296
00297 }
00298 if ( S->LevelOfDetailMask && LevelOfDetailBit )
00299 {
00300 geVec3d *VecDestPtr = &(D->SVPoint);
00301 geXForm3d_Transform( &(ObjectToWorld),
00302 &(S->XPoint),VecDestPtr);
00303 D->SVU = S->XU;
00304 D->SVV = S->XV;
00305 if (VecDestPtr->X > G->Maxs.X ) G->Maxs.X = VecDestPtr->X;
00306 if (VecDestPtr->X < G->Mins.X ) G->Mins.X = VecDestPtr->X;
00307 if (VecDestPtr->Y > G->Maxs.Y ) G->Maxs.Y = VecDestPtr->Y;
00308 if (VecDestPtr->Y < G->Mins.Y ) G->Mins.Y = VecDestPtr->Y;
00309 if (VecDestPtr->Z > G->Maxs.Z ) G->Maxs.Z = VecDestPtr->Z;
00310 if (VecDestPtr->Z < G->Mins.Z ) G->Mins.Z = VecDestPtr->Z;
00311 D->ReferenceBoneIndex=BoneIndex;
00312 }
00313 }
00314 }
00315
00316 {
00317 geBody_Normal *S;
00318 geVec3d *D;
00319 // rotate all appropriate normals
00320 for (i=B->SkinNormalCount,S=B->SkinNormalArray,D=G->NormalArray;
00321 i>0;
00322 i--,S++,D++)
00323 {
00324 if ( S->LevelOfDetailMask && LevelOfDetailBit )
00325 {
00326 geXForm3d_Rotate(&(BoneXFArray[S->BoneIndex]),
00327 &(S->Normal),D);
00328 }
00329 }
00330 }
00331
00332 }
00333
00334
00335 if (LevelOfDetail != BI->LastLevelOfDetail)
00336 {
00337 // build face list to export
00338 int i,j;
00339 geBody_Index Count;
00340 const geBody_Triangle *T;
00341 geBody_Index *D;
00342 Count = B->SkinFaces[LevelOfDetail].FaceCount;
00343
00344 for (i=0,T=B->SkinFaces[LevelOfDetail].FaceArray,D=G->FaceList;
00345 i<Count;
00346 i++,T++,B++)
00347 {
00348 *D = GE_BODYINST_FACE_TRIANGLE;
00349 D++;
00350 *D = T->MaterialIndex;
00351 D++;
00352 for (j=0; j<3; j++)
00353 {
00354 *D = T->VtxIndex[j];
00355 D++;
00356 *D = T->NormalIndex[j];
00357 D++;
00358 }
00359 }
00360 assert( ((uint32)D) - ((uint32)G->FaceList) == (uint32)(G->FaceListSize) );
00361 G->FaceCount = Count;
00362 ((geBodyInst *)BI)->LastLevelOfDetail = LevelOfDetail;
00363 }
00364
00365
00366
00367 return G;
00368 }
|
1.3.2