| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
- //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
- #pragma once
- #include "BsFBXPrerequisites.h"
- #include "BsMatrix4.h"
- #include "BsColor.h"
- #include "BsVector2.h"
- #include "BsVector4.h"
- #include "BsQuaternion.h"
- #include "BsAnimationCurve.h"
- #include "BsSubMesh.h"
- namespace BansheeEngine
- {
- /** @addtogroup FBX
- * @{
- */
- /** Options that control FBX import */
- struct FBXImportOptions
- {
- bool importAnimation = true;
- bool importSkin = true;
- bool importBlendShapes = true;
- bool importNormals = true;
- bool importTangents = true;
- float importScale = 0.01f;
- float animSampleRate = 1.0f / 60.0f;
- bool animResample = false;
- bool reduceKeyframes = true;
- };
- /** Represents a single node in the FBX transform hierarchy. */
- struct FBXImportNode
- {
- ~FBXImportNode();
- Matrix4 localTransform;
- Matrix4 worldTransform;
- String name;
- FbxNode* fbxNode;
- Vector<FBXImportNode*> children;
- };
- /** Contains geometry from one blend shape frame. */
- struct FBXBlendShapeFrame
- {
- Vector<Vector3> positions;
- Vector<Vector3> normals;
- Vector<Vector3> tangents;
- Vector<Vector3> bitangents;
- float weight;
- String name;
- };
- /** Contains all geometry for a single blend shape. */
- struct FBXBlendShape
- {
- String name;
- Vector<FBXBlendShapeFrame> frames;
- };
- /** Contains data about a single bone in a skinned mesh. */
- struct FBXBone
- {
- FBXImportNode* node;
- Matrix4 bindPose;
- };
- /** Contains a set of bone weights and indices for a single vertex, used in a skinned mesh. */
- struct FBXBoneInfluence
- {
- FBXBoneInfluence()
- {
- for (UINT32 i = 0; i < FBX_IMPORT_MAX_BONE_INFLUENCES; i++)
- {
- weights[i] = 0.0f;
- indices[i] = -1;
- }
- }
- float weights[FBX_IMPORT_MAX_BONE_INFLUENCES];
- INT32 indices[FBX_IMPORT_MAX_BONE_INFLUENCES];
- };
- /** Animation curves required to animate a single bone. */
- struct FBXBoneAnimation
- {
- FBXImportNode* node;
- TAnimationCurve<Vector3> translation;
- TAnimationCurve<Quaternion> rotation;
- TAnimationCurve<Vector3> scale;
- };
- /** Animation curve required to animate a blend shape. */
- struct FBXBlendShapeAnimation
- {
- String blendShape;
- TAnimationCurve<float> curve;
- };
- /** Animation clip containing a set of bone or blend shape animations. */
- struct FBXAnimationClip
- {
- String name;
- float start;
- float end;
- UINT32 sampleRate;
- Vector<FBXBoneAnimation> boneAnimations;
- Vector<FBXBlendShapeAnimation> blendShapeAnimations;
- };
- /** All information required for creating an animation clip. */
- struct FBXAnimationClipData
- {
- FBXAnimationClipData(const String& name, bool isAdditive, UINT32 sampleRate, const SPtr<AnimationCurves>& curves)
- :name(name), isAdditive(isAdditive), sampleRate(sampleRate), curves(curves)
- { }
- String name;
- bool isAdditive;
- UINT32 sampleRate;
- SPtr<AnimationCurves> curves;
- };
- /** Imported mesh data. */
- struct FBXImportMesh
- {
- FbxMesh* fbxMesh;
- Vector<int> indices;
- Vector<Vector3> positions;
- Vector<Vector3> normals;
- Vector<Vector3> tangents;
- Vector<Vector3> bitangents;
- Vector<RGBA> colors;
- Vector<Vector2> UV[FBX_IMPORT_MAX_UV_LAYERS];
- Vector<int> materials;
- Vector<int> smoothingGroups;
- Vector<FBXBlendShape> blendShapes;
- Vector<FBXBoneInfluence> boneInfluences;
- Vector<FBXBone> bones;
- SPtr<MeshData> meshData;
- Vector<SubMesh> subMeshes;
- Vector<FBXImportNode*> referencedBy;
- };
- /** Scene information used and modified during FBX import. */
- struct FBXImportScene
- {
- FBXImportScene();
- ~FBXImportScene();
- Vector<FBXImportMesh*> meshes;
- FBXImportNode* rootNode;
- UnorderedMap<FbxNode*, FBXImportNode*> nodeMap;
- UnorderedMap<FbxMesh*, UINT32> meshMap;
- Vector<FBXAnimationClip> clips;
- float scaleFactor;
- Matrix4 globalScale;
- };
- /** @} */
- }
|