Advertisement
Guest User

Untitled

a guest
May 31st, 2017
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 8.31 KB | None | 0 0
  1. // FBXWrapper.h
  2.  
  3. #pragma once
  4.  
  5. #include "stdafx.h"
  6. #include <fbxsdk.h>
  7. #include "FBXWrapper.h"
  8. #include "FBXUtils.h"
  9.  
  10. using namespace System;
  11. using namespace System::Collections::Generic;
  12.  
  13. namespace FBXWrapper { 
  14.     public enum class MappingMode
  15.     {
  16.         eNone,
  17.         eByControlPoint,
  18.         eByPolygonVertex,
  19.         eByPolygon,
  20.         eByEdge,
  21.         eAllSame
  22.     };
  23.  
  24.     public enum class ReferenceMode
  25.     {
  26.         eDirect,
  27.         eIndex,
  28.         eIndexToDirect
  29.     };
  30.  
  31.     public enum class SkelType
  32.     {
  33.         eRoot,
  34.         eLimb, 
  35.         eLimbNode,
  36.         eEffector
  37.     };
  38.  
  39.     public enum class NodeAttribType
  40.     {
  41.         eUnknown,
  42.         eNull,
  43.         eMarker,
  44.         eSkeleton,
  45.         eMesh,
  46.         eNurbs,
  47.         ePatch,
  48.         eCamera,
  49.         eCameraStereo,
  50.         eCameraSwitcher,
  51.         eLight,
  52.         eOpticalReference,
  53.         eOpticalMarker,
  54.         eNurbsCurve,
  55.         eTrimNurbsSurface,
  56.         eBoundary,
  57.         eNurbsSurface,
  58.         eShape,
  59.         eLODGroup,
  60.         eSubDiv,
  61.         eCachedEffect,
  62.         eLine
  63.     };
  64.  
  65.     public enum class EDeformerType
  66.     {
  67.         eUnknown,
  68.         eSkin,
  69.         eBlendShape,
  70.         eVertexCache
  71.     };
  72.  
  73.     public ref class FBXVector4
  74.     {
  75.         public:
  76.             property double X
  77.             {
  78.                 double get()
  79.                 {
  80.                     return vector->mData[0];
  81.                 };
  82.                 void set(double f)
  83.                 {
  84.                     vector->mData[0] = f;
  85.                 }
  86.             };
  87.             property double Y
  88.             {
  89.                 double get()
  90.                 {
  91.                     return vector->mData[1];
  92.                 };
  93.                 void set(double f)
  94.                 {
  95.                     vector->mData[1] = f;
  96.                 }
  97.             };
  98.             property double Z
  99.             {
  100.                 double get()
  101.                 {
  102.                     return vector->mData[3];
  103.                 };
  104.                 void set(double f)
  105.                 {
  106.                     vector->mData[3] = f;
  107.                 }
  108.             };        
  109.             property double W
  110.             {
  111.                 double get()
  112.                 {
  113.                     return vector->mData[3];
  114.                 };
  115.                 void set(double f)
  116.                 {
  117.                     vector->mData[3] = f;
  118.                 }
  119.             };
  120.             FBXVector4();
  121.             FBXVector4(double x, double y, double z, double w);
  122.             FBXVector4(FbxVector4 v);
  123.             FbxVector4* vector;
  124.             List<double>^ ToList();
  125.     };
  126.  
  127.     public ref class FBXAMatrix
  128.     {
  129.         public:
  130.             FbxAMatrix* mat;
  131.             FBXAMatrix();
  132.             FBXAMatrix(FbxAMatrix* m);
  133.             FBXVector4^ getR();
  134.             void SetRow(int Y, FBXVector4^ row);
  135.             void SetTRS(FBXVector4^ lT, FBXVector4^ lR, FBXVector4^ lS);
  136.     };
  137.  
  138.     public ref class FBXCluster
  139.     {
  140.         public:
  141.             FbxCluster* cluster;
  142.             FBXCluster(FbxCluster* c);
  143.             void SetLink(Object^ node);
  144.             void AddControlPointIndex(int idx, double weight);
  145.             void SetTransformMatrix(FBXAMatrix^ mat);
  146.             void SetTransformLinkMatrix(FBXAMatrix^ mat);
  147.             static FBXCluster^ Create(Object^ scene, String^ name);
  148.     };
  149.  
  150.     public ref class FBXGeometryElementNormal
  151.     {
  152.         public:
  153.             FbxGeometryElementNormal* normal;
  154.             FBXGeometryElementNormal(FbxGeometryElementNormal* n);
  155.             void SetMappingMode(MappingMode mode);
  156.             void Add(FBXVector4 ^v);
  157.     };
  158.  
  159.     public ref class FBXGeometryElementBinormal
  160.     {
  161.         public:
  162.             FbxGeometryElementBinormal* binormal;
  163.             FBXGeometryElementBinormal(FbxGeometryElementBinormal* n);
  164.             void SetMappingMode(MappingMode mode);
  165.             void Add(FBXVector4 ^v);
  166.     };
  167.  
  168.     public ref class FBXGeometryElementTangent
  169.     {
  170.         public:
  171.             FbxGeometryElementTangent* tangent;
  172.             FBXGeometryElementTangent(FbxGeometryElementTangent* n);
  173.             void SetMappingMode(MappingMode mode);
  174.             void Add(FBXVector4 ^v);
  175.     };
  176.  
  177.     public ref class FBXGeometryElementMaterial
  178.     {
  179.         public:
  180.             FbxGeometryElementMaterial* mat;
  181.             FBXGeometryElementMaterial(FbxGeometryElementMaterial* m);
  182.             void SetMappingMode(MappingMode mode);
  183.             void SetReferenceMode(ReferenceMode mode);
  184.     };
  185.  
  186.     public ref class FBXGeometryElementUV
  187.     {
  188.         public:
  189.             FbxGeometryElementUV* uv;
  190.             FBXGeometryElementUV(FbxGeometryElementUV* t);
  191.             void SetMappingMode(MappingMode mode);
  192.             void SetReferenceMode(ReferenceMode mode);
  193.             void SetIndexArrayCount(int count);
  194.             void Add(FBXVector4 ^v);
  195.     };
  196.  
  197.     public ref class FBXNodeAttribute
  198.     {
  199.         public:
  200.             FbxNodeAttribute* attrib;
  201.             FBXNodeAttribute(FbxNodeAttribute* a);
  202.             NodeAttribType GetAttributeType();
  203.             Object^ ToGeometry();
  204.     };
  205.  
  206.     public ref class FBXNode
  207.     {
  208.         public:
  209.             FbxNode* node;
  210.             property List<double>^ LclTranslation
  211.             {
  212.                 List<double>^ get()
  213.                 {
  214.                     List<double>^ result = gcnew List<double>();
  215.                     FbxDouble3 tmp = node->LclTranslation.Get();
  216.                     result->Add(tmp.mData[0]);
  217.                     result->Add(tmp.mData[1]);
  218.                     result->Add(tmp.mData[2]);
  219.                     return result;
  220.                 }
  221.                 void set(List<double>^ l)
  222.                 {
  223.                     FbxDouble3 tmp;
  224.                     tmp.mData[0] = l[0];
  225.                     tmp.mData[1] = l[1];
  226.                     tmp.mData[2] = l[2];
  227.                     node->LclTranslation.Set(tmp);
  228.                 }
  229.             }
  230.             property List<double>^ LclRotation
  231.             {
  232.                 List<double>^ get()
  233.                 {
  234.                     List<double>^ result = gcnew List<double>();
  235.                     FbxDouble3 tmp = node->LclRotation.Get();
  236.                     result->Add(tmp.mData[0]);
  237.                     result->Add(tmp.mData[1]);
  238.                     result->Add(tmp.mData[2]);
  239.                     return result;
  240.                 }
  241.                 void set(List<double>^ l)
  242.                 {
  243.                     FbxDouble3 tmp;
  244.                     tmp.mData[0] = l[0];
  245.                     tmp.mData[1] = l[1];
  246.                     tmp.mData[2] = l[2];
  247.                     node->LclRotation.Set(tmp);
  248.                 }
  249.             }
  250.  
  251.             FBXNode(FbxNode* n);
  252.  
  253.             static FBXNode^ Create(Object^ scene, String^ name);
  254.             void AddChild(FBXNode^ node);
  255.             FBXNode^ FindChild(String^ name);
  256.             FBXNode^ GetParent();
  257.             void SetNodeAttribute(Object^ obj);
  258.             void AddMaterial(Object^ scene, String^ name);
  259.             FBXAMatrix^ EvaluateGlobalTransform();
  260.             FBXNodeAttribute^ GetNodeAttribute();
  261.             bool Equals(FBXNode^ n);
  262.             Object^ GetMesh();
  263.     };
  264.  
  265.     public ref class FBXManager
  266.     {
  267.         public:
  268.             FbxManager* manager;
  269.     };
  270.  
  271.     public ref class FBXScene
  272.     {
  273.         public:
  274.             FbxScene* scene;
  275.             FBXNode^ GetRootNode();
  276.             void AddPose(Object^ pose);
  277.     };
  278.  
  279.     public ref class FBXMesh
  280.     {
  281.         public:
  282.             FbxMesh* mesh;
  283.  
  284.             FBXMesh(FbxMesh* m);
  285.  
  286.             static FBXMesh^ Create(FBXScene^ scene, String^ name);
  287.             FBXGeometryElementNormal^ CreateElementNormal();
  288.             FBXGeometryElementBinormal^ CreateElementBinormal();
  289.             FBXGeometryElementTangent^ CreateElementTangent();
  290.             FBXGeometryElementMaterial^ CreateElementMaterial();
  291.             FBXGeometryElementUV^ CreateElementUV(String^ MeshName);
  292.             void InitControlPoints(int count);
  293.             void SetControlPoint(int n, FBXVector4^ v);
  294.             void BeginPolygon();
  295.             void BeginPolygon(int i);
  296.             void EndPolygon();
  297.             void AddPolygon(int idx);
  298.             void AddDeformer(Object^ shape);
  299.             int GetControlPointsCount();
  300.     };
  301.  
  302.     public ref class FBXSkeleton
  303.     {
  304.         public:
  305.             FbxSkeleton* skeleton;
  306.             FBXSkeleton(FbxSkeleton* skel);
  307.             void SetSkeletonType(SkelType type);
  308.             void SetSize(double d);
  309.             static FBXSkeleton^ Create(FBXScene^ scene, String^ name);
  310.     };
  311.  
  312.     public ref class FBXSkin
  313.     {
  314.         public:
  315.             FbxSkin* skin;
  316.             FBXSkin(FbxSkin* s);
  317.             void AddCluster(FBXCluster^ c);
  318.             int GetClusterCount();
  319.             FBXNode^ GetClusterLink(int i);
  320.             static FBXSkin^ Create(FBXScene^ scene, String^ name);
  321.     };
  322.  
  323.     public ref class FBXGeometry
  324.     {
  325.         public:
  326.             FbxGeometry* geo;
  327.             FBXGeometry(FbxGeometry* g);
  328.             void AddDeformer(FBXSkin^ skin);
  329.             int GetDeformerCount(EDeformerType type);
  330.             FBXSkin^ GetSkinDeformer(int n);
  331.     };
  332.  
  333.     public ref class FBXPose
  334.     {
  335.         public:
  336.             FbxPose* pose;
  337.             FBXPose(FbxPose* p);
  338.             void SetIsBindPose(bool b);
  339.             void Add(FBXNode^ n, FBXAMatrix^ mat);
  340.             static FBXPose^ Create(FBXScene^ scene, String^ name);
  341.     };
  342.  
  343.     public ref class FBXShape
  344.     {
  345.         public:
  346.             FbxShape* shape;
  347.             FBXShape(FbxShape* s);
  348.             void InitControlPoints(int n);
  349.             List<FBXVector4^>^ GetControlPoints();
  350.             static FBXShape^ Create(FBXScene^ scene, String^ name);
  351.     };
  352.  
  353.     public ref class FBXBlendShape
  354.     {
  355.         public:
  356.             FbxBlendShape* shape;
  357.             FBXBlendShape(FbxBlendShape* s);
  358.             void AddBlendShapeChannel(Object^ c);
  359.             static FBXBlendShape^ Create(FBXScene^ scene, String^ name);
  360.     };
  361.  
  362.     public ref class FBXBlendShapeChannel
  363.     {
  364.         public:
  365.             FbxBlendShapeChannel* channel;
  366.             FBXBlendShapeChannel(FbxBlendShapeChannel* c);
  367.             void AddTargetShape(FBXShape^ shape);
  368.             static FBXBlendShapeChannel^ Create(FBXScene^ scene, String^ name);
  369.     };
  370.  
  371.     public ref class FBXHelper
  372.     {
  373.         public:
  374.             FBXUtils FbxUtils;
  375.             static void InitializeSdkObjects(FBXManager^ manager, FBXScene^ scene);
  376.             static void DestroySdkObjects(FBXManager^ manager, bool result);
  377.             static bool SaveScene(FBXManager^ manager, FBXScene^ scene, String^ targetDir);
  378.             static bool SaveScene(FBXManager^ manager, FBXScene^ scene, String^ targetDir, int pFileFormat, bool pEmbedMedia);
  379.             static void SetGlobalDefaultPosition(FBXNode^ n, FBXAMatrix^ m);
  380.     };
  381. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement