DATAKIT SDK  V2026.1
testlibfbxwrite.cpp File Reference

Functions

Dtk_ErrorStatus FbxwInstances (const Dtk_string &outputFileName)
 
int FbxWriteSample (const Dtk_string &inResultDirectory)
 
Dtk_ErrorStatus FbxwTwoMeshes (const Dtk_string &outputFileName)
 

Function Documentation

◆ FbxwInstances()

Dtk_ErrorStatus FbxwInstances ( const Dtk_string outputFileName)
54 { // SAMPLE 2
55  Dtk_MeshPtr CubeMesh;
56  // Cube Sample
57  CubeMesh = sampleWriter::CreateMeshCube();
58  Dtk_transfo cubetransfo;
59  Dtk_bool useless, wasreinstancied; // useless for this sample
60 
61  // For this sample, i will write 10 instances of cube.
62  // the matrix given is shifted in all iterations
63  // Inside the for below, we give an ID to OpenInstance. Then we add the cube, and close the child.
64  // For all others instances, we give the same ID to OpenInstance, and just close the child. Fbx Writer will recognize the ID and automatic reinstance the cube with another matrix.
66  // First we initialize writing with name of files and protection fonction if needed (3rd parameter)
67  Dtk_FBXWriter Fb( outputFileName, err );
68  if( err != dtkNoError )
69  return err;
70  Fb.OpenInstance( "RootNode", -1, useless );
71  int i;
72  for( i = 0; i < 10; i++ )
73  {
74  Fb.OpenInstance( "Cube", 1, wasreinstancied, cubetransfo ); // Giving ID 1
75  if( !wasreinstancied )
76  {
77  Fb.WriteMesh( CubeMesh );
78  }
79  Fb.CloseLastInstance();
80  cubetransfo.addTranslate( Dtk_dir( 10, 0, 0 ) ); // shift matrix.
81  }
82  Fb.CloseLastInstance();
83  return dtkNoError;
84 }

◆ FbxWriteSample()

int FbxWriteSample ( const Dtk_string inResultDirectory)
88 {
89  Dtk_string outputDirectory, fileName;
90  cout << endl << "----------------------------------------------" << endl;
91 
92  // Choosing output directory and file name
93  outputDirectory = inResultDirectory + L"Fbx/";
94  outputDirectory.FixPathSeparator();
95  outputDirectory.mkdir();
96 
97  cout << "Fbx Write start" << endl;
98  // sample 1 : just wirte 2 meshes
99  fileName = outputDirectory + L"twomeshes.fbx";
100  Dtk_ErrorStatus err = FbxwTwoMeshes( fileName );
101  if( err == dtkNoError )
102  cout << "=> " << fileName.c_str() << endl;
103  else
104  cout << "error : " << dtkTypeError( err ).c_str() << endl;
105 
106  // sample 2 : write instances
107  fileName = outputDirectory + L"twomeshes.fbx";
108  err = FbxwInstances( fileName );
109  if( err == dtkNoError )
110  cout << "=> " << fileName.c_str() << endl;
111  else
112  cout << "error : " << dtkTypeError( err ).c_str() << endl;
113 
114  cout << "Fbx Write end" << endl;
115 
116  return err;
117 }

◆ FbxwTwoMeshes()

Dtk_ErrorStatus FbxwTwoMeshes ( const Dtk_string outputFileName)
13 { // SAMPLE 1
14  Dtk_MeshPtr CubeMesh, CylinderMesh;
15  Dtk_bool useless; // useless for this sample
16  // Cube Sample
17  CubeMesh = sampleWriter::CreateMeshCube();
18  // Cylinder Sample
19  CylinderMesh = sampleWriter::CreateMeshCylinder( 30 );
20 
22  // First we initialize writing with name of files and protection fonction if needed (3rd parameter)
23  Dtk_FBXWriter Fb( outputFileName, err );
24  if( err != dtkNoError )
25  return err;
26 
27  // Rootnode creation
28  Fb.OpenInstance( "RootNode", -1, useless );
29 
30  // from this node, create a Child for the cube, and naming it "Cube"
31  Fb.OpenInstance( "Cube", -1, useless );
32  // write the cube
33  Fb.WriteMesh( CubeMesh );
34 
35  // close the cube node
36  Fb.CloseLastInstance();
37 
38  // from root node again, create a Child for the cylinder, and naming it "Cylinder"
39  Fb.OpenInstance( "Cylinder", -1, useless );
40  // write the cube
41  Fb.WriteMesh( CylinderMesh );
42  // close the cube node
43  Fb.CloseLastInstance();
44 
45  // Rootnode closing.
46  Fb.CloseLastInstance();
47 
48  // CLeaning class save file
49  return dtkNoError;
50 }
Dtk_transfo
This is the Transformation dedicated class.
Definition: dtk_transfo.hpp:19
sampleWriter::CreateMeshCube
Dtk_MeshPtr CreateMeshCube()
Mesh Cube sample.
Definition: testcreatemesh.cpp:204
FbxwInstances
Dtk_ErrorStatus FbxwInstances(const Dtk_string &outputFileName)
Definition: testlibfbxwrite.cpp:53
Dtk_string
This is a high level string class.
Definition: dtk_string.hpp:53
Dtk_bool
char Dtk_bool
Definition: define.h:728
Dtk_FBXWriter
FBX Writer main class.
Definition: fbxw.hpp:10
FbxwTwoMeshes
Dtk_ErrorStatus FbxwTwoMeshes(const Dtk_string &outputFileName)
Definition: testlibfbxwrite.cpp:12
Dtk_ErrorStatus
Dtk_ErrorStatus
Definition: error_dtk.hpp:6
Dtk_SmartPtr
Definition: util_ptr_dtk.hpp:37
dtkTypeError
Dtk_string dtkTypeError(Dtk_Int32 errNumero)
Dtk_string::c_str
const char * c_str() const
Retrieve the ASCII conversion string.
sampleWriter::CreateMeshCylinder
Dtk_MeshPtr CreateMeshCylinder(int nbpoints)
Mesh Cylinder sample.
Definition: testcreatemesh.cpp:334
Dtk_string::mkdir
int mkdir() const
File Utility : Create a Directory.
Dtk_string::FixPathSeparator
void FixPathSeparator()
File Utility : Fixes path separator consistency. It lets you replace the '\' or '/' by the OS needed ...
Dtk_transfo::addTranslate
void addTranslate(const Dtk_dir &V)
Translate the Dtk_transfo.
dtkNoError
@ dtkNoError
Definition: error_dtk.hpp:147
Dtk_dir
This is a mathematical direction class.
Definition: dtk_dir.hpp:14