Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
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 <algorithm>
#include <cassert>
#include <libxml/xmlerror.h>
Include dependency graph for CommonConvert.cpp:

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

◆ errorHandler()

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

Error handler for libxml2.

◆ FindInstances()

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

◆ FindSingleInstance()

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

◆ FindSkeleton()

const Skeleton & FindSkeleton ( const FCDControllerInstance &  controllerInstance)

Finds the skeleton definition which best matches the given controller.

Exceptions
ColladaExceptionif none is found.

◆ FixSkeletonRoots()

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.

◆ FMMatrix44_Identity()

FMMatrix44 FMMatrix44_Identity ( identity  )

◆ FMVector3_XAxis()

const FMVector3 FMVector3_XAxis ( 1.  0f,
0.  0f,
0.  0f 
)

◆ IsVisible()

static bool IsVisible ( FCDSceneNode *  node)
static

◆ IsVisible_XSI()

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

◆ require_()

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

◆ ReverseSortWeight()

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

◆ SkinReduceInfluences()

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.

◆ TransformBones()

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.

Variable Documentation

◆ identity

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