Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Functions | Variables
CommonConvert.cpp File Reference
#include "precompiled.h"
#include "CommonConvert.h"
#include "StdSkeletons.h"
#include "XMLFix.h"
#include "FCollada.h"
#include "FCDocument/FCDSceneNode.h"
#include "FCDocument/FCDSkinController.h"
#include "FUtils/FUDaeSyntax.h"
#include "FUtils/FUFileManager.h"
#include <cassert>
#include <algorithm>

Go to the source code of this file.

Classes

struct  FoundInstance
 

Functions

void require_ (int line, bool value, const char *type, const char *message)
 
void errorHandler (void *ctx, const char *msg,...)
 Error handler for libxml2. More...
 
const FMVector3 FMVector3_XAxis (1.0f, 0.0f, 0.0f)
 
FMMatrix44 FMMatrix44_Identity (identity)
 
static bool IsVisible_XSI (FCDSceneNode *node, bool &visible)
 
static bool IsVisible (FCDSceneNode *node)
 
static void FindInstances (FCDSceneNode *node, std::vector< FoundInstance > &instances, const FMMatrix44 &transform, bool onlyMarked)
 Recursively finds all entities under the current node. More...
 
bool FindSingleInstance (FCDSceneNode *node, FCDEntityInstance *&instance, FMMatrix44 &transform)
 Tries to find a single suitable entity instance in the scene. More...
 
static bool ReverseSortWeight (const FCDJointWeightPair &a, const FCDJointWeightPair &b)
 
void SkinReduceInfluences (FCDSkinController *skin, size_t maxInfluenceCount, float minimumWeight)
 Like FCDSkinController::ReduceInfluences but works correctly. More...
 
void FixSkeletonRoots (FCDControllerInstance &controllerInstance)
 Fixes some occasional problems with the skeleton root definitions in a controller. More...
 
const SkeletonFindSkeleton (const FCDControllerInstance &controllerInstance)
 Finds the skeleton definition which best matches the given controller. More...
 
void TransformBones (std::vector< BoneTransform > &bones, const FMMatrix44 &scaleTransform, bool yUp)
 Performs the standard transformations on bones, applying a scale matrix and moving them into the game's coordinate space. More...
 

Variables

static float identity [] = { 1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1 }
 

Function Documentation

void errorHandler ( void *  ctx,
const char *  msg,
  ... 
)

Error handler for libxml2.

Definition at line 43 of file CommonConvert.cpp.

static void FindInstances ( FCDSceneNode *  node,
std::vector< FoundInstance > &  instances,
const FMMatrix44 &  transform,
bool  onlyMarked 
)
static

Recursively finds all entities under the current node.

If onlyMarked is set, only matches entities where the user-defined property was set to "export" in the modelling program.

Parameters
noderoot of subtree to search
instancesoutput - appends matching entities
transformtransform matrix of current subtree
onlyMarkedonly match entities with "export" property

Definition at line 232 of file CommonConvert.cpp.

bool FindSingleInstance ( FCDSceneNode *  node,
FCDEntityInstance *&  instance,
FMMatrix44 &  transform 
)

Tries to find a single suitable entity instance in the scene.

Fails if there are none, or if there are too many and it's not clear which one should be converted.

Parameters
noderoot scene node to search under
instanceoutput - the found entity instance (if any)
transform- the world-space transform of the found entity
Returns
true if one was found

Definition at line 265 of file CommonConvert.cpp.

const Skeleton& FindSkeleton ( const FCDControllerInstance &  controllerInstance)

Finds the skeleton definition which best matches the given controller.

Exceptions
ColladaExceptionif none is found.

Definition at line 381 of file CommonConvert.cpp.

void FixSkeletonRoots ( FCDControllerInstance &  controllerInstance)

Fixes some occasional problems with the skeleton root definitions in a controller.

(In particular, it's needed for models exported from XSI.) Should be called before extracting any joint information from the controller.

Definition at line 363 of file CommonConvert.cpp.

FMMatrix44 FMMatrix44_Identity ( identity  )
const FMVector3 FMVector3_XAxis ( 1.  0f,
0.  0f,
0.  0f 
)
static bool IsVisible ( FCDSceneNode *  node)
static

Definition at line 209 of file CommonConvert.cpp.

static bool IsVisible_XSI ( FCDSceneNode *  node,
bool &  visible 
)
static

Definition at line 183 of file CommonConvert.cpp.

void require_ ( int  line,
bool  value,
const char *  type,
const char *  message 
)

Definition at line 34 of file CommonConvert.cpp.

static bool ReverseSortWeight ( const FCDJointWeightPair &  a,
const FCDJointWeightPair &  b 
)
static

Definition at line 298 of file CommonConvert.cpp.

void SkinReduceInfluences ( FCDSkinController *  skin,
size_t  maxInfluenceCount,
float  minimumWeight 
)

Like FCDSkinController::ReduceInfluences but works correctly.

Additionally, multiple influences for the same joint-vertex pair are collapsed into a single influence.

Definition at line 303 of file CommonConvert.cpp.

void TransformBones ( std::vector< BoneTransform > &  bones,
const FMMatrix44 &  scaleTransform,
bool  yUp 
)

Performs the standard transformations on bones, applying a scale matrix and moving them into the game's coordinate space.

Definition at line 397 of file CommonConvert.cpp.

Variable Documentation

float identity[] = { 1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1 }
static

Definition at line 174 of file CommonConvert.cpp.