Added: #1440 Some notes on PolyObject format

--HG--
branch : build_pipeline_v3
hg/feature/build_pipeline_v3
kaetemi 12 years ago
parent fe82439b97
commit 3a09142dc7

@ -32,8 +32,7 @@
#include <sstream>
// NeL includes
// #include <nel/misc/debug.h>
#include <nel/misc/vector.h>
// #include <nel/misc/debug.h>s
// Project includes
#include "../../storage_array.h"
@ -66,7 +65,7 @@ namespace STORAGE {
#define PMBS_GEOM_BUFFERS_TRI_C_VERTEX_CHUNK_ID 0x0938
#define PMBS_GEOM_BUFFERS_TRI_C_INDEX_CHUNK_ID 0x0942
#define PBMS_GEOM_BUFFERS_POLY_A_VERTEX_CHUNK_ID 0x0100
#define PBMS_GEOM_BUFFERS_POLY_A_INDEX_A_CHUNK_ID 0x010a
#define PBMS_GEOM_BUFFERS_POLY_A_EDGE_CHUNK_ID 0x010a
#define PBMS_GEOM_BUFFERS_POLY_A_INDEX_B_CHUNK_ID 0x011a
////////////////////////////////////////////////////////////////////////
@ -111,6 +110,41 @@ std::string CGeomTriIndexInfo::toString() const
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
void CGeomPolyVertexInfo::serial(NLMISC::IStream &stream)
{
stream.serial(i1);
stream.serial(v);
}
std::string CGeomPolyVertexInfo::toString() const
{
std::stringstream ss;
ss << "0x" << NLMISC::toString("%x", i1) << ", " << v.toString();
return ss.str();
}
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
void CGeomPolyEdgeInfo::serial(NLMISC::IStream &stream)
{
stream.serial(i1);
stream.serial(a);
stream.serial(b);
}
std::string CGeomPolyEdgeInfo::toString() const
{
std::stringstream ss;
ss << "0x" << NLMISC::toString("%x", i1) << ", " << a << " " << b;
return ss.str();
}
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
CGeomBuffers::CGeomBuffers()
{
@ -155,13 +189,17 @@ IStorageObject *CGeomBuffers::createChunkById(uint16 id, bool container)
{
switch (id)
{
//case PBMS_GEOM_BUFFERS_POLY_A_VERTEX_CHUNK_ID:
// nlassert(!container);
// return new CStorageArray<float>();
//case PBMS_GEOM_BUFFERS_POLY_A_INDEX_A_CHUNK_ID:
//case PBMS_GEOM_BUFFERS_POLY_A_INDEX_B_CHUNK_ID:
// nlassert(!container);
// return new CStorageArray<uint32>();
case PBMS_GEOM_BUFFERS_POLY_A_VERTEX_CHUNK_ID:
nlassert(!container);
return new CStorageArraySizePre<CGeomPolyVertexInfo>();
case PBMS_GEOM_BUFFERS_POLY_A_EDGE_CHUNK_ID:
nlassert(!container);
return new CStorageArraySizePre<CGeomPolyEdgeInfo>();
case PMBS_GEOM_BUFFERS_TRI_B_INDEX_CHUNK_ID:
case PMBS_GEOM_BUFFERS_TRI_C_INDEX_CHUNK_ID:
nlassert(!container);

@ -32,6 +32,7 @@
// STL includes
// NeL includes
#include <nel/misc/vector.h>
// Project includes
#include "../../storage_object.h"
@ -61,6 +62,23 @@ struct CGeomTriIndexInfo
std::string toString() const;
};
struct CGeomPolyVertexInfo
{
uint32 i1;
NLMISC::CVector v;
void serial(NLMISC::IStream &stream);
std::string toString() const;
};
struct CGeomPolyEdgeInfo
{
uint32 i1;
uint32 a;
uint32 b;
void serial(NLMISC::IStream &stream);
std::string toString() const;
};
/**
* \brief CGeomBuffers
* \date 2012-08-25 07:55GMT

@ -926,3 +926,241 @@ ver2010
01 00 00 00 // one face
04 00 00 00 // four edges/vertices
02 00 00 00 // 2
00 00 00 00 // 0
01 00 00 00 // 1
03 00 00 00 // 3
30 00 // nomnom
01 00 00 00 // nomnom
01 00 00 00 // nomnom
03 00 00 00 // nomnom
////// banner
c2 00 00 00 // 194 faces
04 00 00 00 // four vertices
00 00 00 00
01 00 00 00
2e 00 00 00
2d 00 00 00
31 00 // magic
0c 00 00 00 // magic
08 00 00 00 // more magic?!
01 00 00 00 // cut from local 1
03 00 00 00 // to local 3
04 00 00 00 // four vertices
01 00 00 00
02 00 00 00
2f 00 00 00
2e 00 00 00
31 00 // magic
04 00 00 00 // magic
08 00 00 00 // more magic?!
01 00 00 00 // cut from local 1
03 00 00 00 // to local 3
04 00 00 00
02 00 00 00
03 00 00 00
30 00 00 00
2f 00 00 00
31 00
04 00 00 00
08 00 00 00
01 00 00 00
03 00 00 00
04 00 00 00
03 00 00 00
04 00 00 00
31 00 00 00
30 00 00 00
31 00
0c 00 00 00
08 00 00 00
01 00 00 00
03 00 00 00
04 00 00 00
04 00 00 00 00 00 00 00 2d 00 00 00 31 00 00 00
31 00
0c 00 00 00 08 00 00 00
01 00 00 00 03 00 00 00
04 00 00 00
14 00 00 00 13 00 00 00 19 00 00 00 18 00 00 00
39 00
0c 00 00 00
09 00
08 00 00 00
02 00 00 00
00 00 00 00
04 00 00 00 13 00 00 00 15 00 00 00 1a 00 00 00 19 00 00 00
39 00 04 00 00 00
09 00 08 00 00 00
02 00 00 00 00 00 00 00 04 00 00 00 15 00 00 00 16 00 00 00 1b 00 00 00 1a 00 00 00 39 00 04 00 00 00 09 00 08 00 00 00 02 00 00 00 00 00 00 00 04 00 00 00 16 00 00 00 17 00 00 00 1c 00 00 00 1b 00 00 00 39 00 0c 00 00 00 09 00 08 00 00 00 02 00 00 00 00 00 00 00 04 00 00 00 17 00 00 00 14 00 00 00 18 00 00 00 1c 00 00 00 39 00 0c 00 00 00 09 00 08 00 00 00 02 00 00 00 00 00 00 00 04 00 00 00 0b 00 00 00 0a 00 00 00 1f 00 00 00 20 00 00 00 31 00 04 00 00 00 08 00 00 00 00 00 00 00 02 00 00 00 04 00 00 00 0a 00 00 00 09 00 00 00 1e 00 00 00 1f 00 00 00 31 00 0c 00 00 01 08 00 00 00 00 00 00 00 02 00 00 00 04 00 00 00 0c 00 00 00 0b 00 00 00 20 00 00 00 21 00 00 00 31 00 04 00 00 00 08 00 00 00 00 00 00 00 02 00 0
////// banner
3 0x0100: (StorageArraySizePre) [6] { { 0x0, -5.000000 -5.000000 0.000000 } { 0x1000000, 5.000000 -5.000000 0.000000 } { 0x0, -5.000000 5.000000 0.000000 } { 0x1000000, 5.000000 5.000000 0.000000 } { 0x0, 5.000000 -5.000000 10.000000 } { 0x0, 5.000000 5.000000 10.000000 } }
4 0x010a: (StorageArraySizePre) [7] { { 0x0, 2 0 } { 0x0, 3 2 } { 0x0, 1 3 } { 0x0, 0 1 } { 0x0, 1 4 } { 0x0, 5 3 } { 0x1, 4 5 } }
5 0x011a: (StorageRaw) {
Size: 68
String: ........................0................................. .........
Hex:
02 00 00 00 // 2 faces!
04 00 00 00 // 4 vertices
02 00 00 00
00 00 00 00
01 00 00 00 // shared
03 00 00 00 // shared
30 00
01 00 00 00
01 00 00 00
03 00 00 00
04 00 00 00 // 4 vertices
03 00 00 00 // shared
01 00 00 00 // shared
04 00 00 00
05 00 00 00
20 00
00 00 00 00
02 00 00 00 }
3 0x0100: (StorageArraySizePre) [8] { { 0x0, -5.000000 -5.000000 0.000000 } { 0x0, 5.000000 -5.000000 0.000000 } { 0x0, -5.000000 5.000000 0.000000 } { 0x0, 5.000000 5.000000 0.000000 } { 0x1000000, 5.000000 -5.000000 10.000000 } { 0x1000000, 5.000000 5.000000 10.000000 } { 0x0, -5.000000 -5.000000 10.000000 } { 0x0, -5.000000 5.000000 10.000000 } }
4 0x010a: (StorageArraySizePre) [10] { { 0x8, 2 0 } { 0x8, 3 2 } { 0x8, 1 3 } { 0x8, 0 1 } { 0x8, 1 4 } { 0x8, 5 3 } { 0x0, 4 5 } { 0x0, 4 6 } { 0x0, 7 5 } { 0x0, 6 7 } }
5 0x011a: (StorageRaw) {
Size: 106
String: ........................1.....................................!................................. .........
Hex:
03 00 00 00 // 3 faces
04 00 00 00 // 4 vertices
02 00 00 00
00 00 00 00
01 00 00 00
03 00 00 00
31 00 // 0011 0001
08 00 00 00
01 00 00 00
01 00 00 00
03 00 00 00
04 00 00 00 // 4 vertices
03 00 00 00
01 00 00 00
04 00 00 00 // shared vertex
05 00 00 00 // shared vertex
21 00 // 0010 0001
08 00 00 00
00 00 00 00
02 00 00 00
04 00 00 00 // 4 vertices
05 00 00 00 // shared vertex
04 00 00 00 // shared vertex
06 00 00 00
07 00 00 00
20 00 // 0010 0000
00 00 00 00
02 00 00 00 }
** triangulation is stored inside the polyobject somewhere with the faces!
3 0x0100: (StorageArraySizePre) [5] { { 0x0, -5.000000 -2.000000 0.000000 } { 0x0, 1.169249 -6.003741 0.000000 } { 0x0, -3.931087 3.378710 0.000000 } { 0x0, 3.007738 4.420538 0.000000 } { 0x0, 5.070167 -1.944196 0.000000 } }
4 0x010a: (StorageArraySizePre) [5] { { 0x0, 2 0 } { 0x0, 3 2 } { 0x0, 1 4 } { 0x0, 0 1 } { 0x0, 4 3 } }
5 0x011a: (StorageRaw) {
Size: 50
String: ............................0.....................
Hex:
01 00 00 00 // 1 face
05 00 00 00
02 00 00 00
00 00 00 00 // v0 at idx 1
01 00 00 00
04 00 00 00
03 00 00 00
30 00 // triangulation egdes should both touch vertex 0... locally 1?
01 00 00 00
01 00 00 00
03 00 00 00
01 00 00 00
oops deleted
Float: 4.2039e-45 }
3 0x0100: (StorageArraySizePre) [5] { { 0x0, -5.000000 -2.000000 0.000000 } { 0x0, 1.169249 -6.003741 0.000000 } { 0x0, -3.931087 3.378710 0.000000 } { 0x0, 3.007738 4.420538 0.000000 } { 0x0, 5.070167 -1.944196 0.000000 } }
4 0x010a: (StorageArraySizePre) [5] { { 0x0, 2 0 } { 0x0, 3 2 } { 0x0, 1 4 } { 0x0, 0 1 } { 0x0, 4 3 } }
5 0x011a: (StorageRaw) {
Size: 50
String: ............................0.....................
Hex:
01 00 00 00
05 00 00 00
02 00 00 00
00 00 00 00
01 00 00 00 // v1 at idx 2
04 00 00 00
03 00 00 00
30 00 30 00 // triangle edges should both touch vertex 1... locally 2?
01 00 00 00 01 00 00 00
00 00 00 00 01 00 00 00
02 00 00 00 03 00 00 00
02 00 00 00 01 00 00 00 // hm!
04 00 00 00 oops deleted }
3 0x0100: (StorageArraySizePre) [5] { { 0x0, -5.000000 -2.000000 0.000000 } { 0x0, 1.169249 -6.003741 0.000000 } { 0x0, -3.931087 3.378710 0.000000 } { 0x0, 3.007738 4.420538 0.000000 } { 0x1, 5.070167 -1.944196 0.000000 } }
4 0x010a: (StorageArraySizePre) [5] { { 0x0, 2 0 } { 0x0, 3 2 } { 0x0, 1 4 } { 0x0, 0 1 } { 0x0, 4 3 } }
5 0x011a: (StorageRaw) {
Size: 50
String: ............................0.....................
Hex:
01 00 00 00
05 00 00 00
02 00 00 00
00 00 00 00
01 00 00 00
04 00 00 00
03 00 00 00
30 00 // magic // triangle edges should touch vertex 4 .. locally 3?
01 00 00 00 // magic
01 00 00 00 // triangulate from local 1
03 00 00 00 // to local 3
00 00 00 00 // triangulate from local 0
03 00 00 00 // to local 3 }
3 0x0100: (StorageArraySizePre) [3] { { 0x0, -5.000000 -2.000000 0.000000 } { 0x0, 1.169249 -6.003741 0.000000 } { 0x0, 5.070167 -1.944196 0.000000 } }
4 0x010a: (StorageArraySizePre) [3] { { 0x0, 1 2 } { 0x0, 0 1 } { 0x1, 2 0 } }
5 0x011a: (StorageRaw) {
Size: 26
String: ..........................
Hex:
01 00 00 00
03 00 00 00
00 00 00 00
01 00 00 00
02 00 00 00
10 00
01 00 00 00 }
01 00 00 00
05 00 00 00
02 00 00 00
00 00 00 00
01 00 00 00
04 00 00 00
03 00 00 00
31 00 /// 20 00 = info, last; 10 00 = smoothing groups; 01 00 = ??
01 00 01 00
ff ff ff ff // smoothing group
01 00 00 00 03 00 00 00 // cut 1
00 00 00 00 03 00 00 00 // cut 1 }

@ -40,15 +40,15 @@ using namespace PIPELINE::MAX;
using namespace PIPELINE::MAX::BUILTIN;
using namespace PIPELINE::MAX::BUILTIN::STORAGE;
static const char *filename = "/srv/work/database/interfaces/anims_max/cp_fy_hof_species.max";
//static const char *filename = "/srv/work/database/interfaces/anims_max/cp_fy_hof_species.max";
//static const char *filename = "/home/kaetemi/source/minimax/GE_Acc_MikotoBaniere.max";
//static const char *filename = "/home/kaetemi/3dsMax/scenes/test2008.max";
//static const char *filename = "/home/kaetemi/3dsMax/scenes/teapot_test_scene.max";
static const char *filename = "/home/kaetemi/3dsMax/scenes/testplane.max";
static const char *streamname = "Scene";
void exportObj(const std::string &fileName, const CReferenceMaker *triObject)
{
triObject->toString(std::cout);
IStorageObject *bufferBlock = triObject->findStorageObject(0x08fe);
nlassert(bufferBlock->isContainer());
CStorageContainer *buffers = static_cast<CStorageContainer *>(bufferBlock);
@ -190,9 +190,9 @@ int main(int argc, char **argv)
nldebug("PARSE");
scene.parse(PIPELINE::MAX::VersionUnknown); // parse the structure to readable data
nldebug("CLEAN");
// scene.clean(); // cleanup unused file structure, don't clean up if we want direct access to chunks as well
//## scene.clean(); // cleanup unused file structure, don't clean up if we want direct access to chunks as well
// <- TEST
// scene.toString(std::cout);
//## scene.toString(std::cout);
std::cout << "\n";
//classDirectory3.build(PIPELINE::MAX::VersionUnknown);
//classDirectory3.disown();
@ -203,8 +203,17 @@ int main(int argc, char **argv)
scene.container()->scene()->rootNode()->dumpNodes(std::cout);
std::cout << "\n";
PIPELINE::MAX::BUILTIN::INode *node = scene.container()->scene()->rootNode()->find(ucstring("TR_HOF_civil01_gilet")); nlassert(node);
exportObj("tr_hof_civil01_gilet.obj", node->getReference(1)->getReference(1));
//PIPELINE::MAX::BUILTIN::INode *node = scene.container()->scene()->rootNode()->find(ucstring("TR_HOF_civil01_gilet")); nlassert(node);
//node->toString(std::cout);
//exportObj("tr_hof_civil01_gilet.obj", node->getReference(1)->getReference(1)); // => CDerivedObject::getBase(node->object())
//INode *node = scene.container()->scene()->rootNode()->find(ucstring("GE_Acc_MikotoBaniere")); nlassert(node);
INode *node = scene.container()->scene()->rootNode()->find(ucstring("testplane")); nlassert(node);
CReferenceMaker *object = node->getReference(1);
object->toString(std::cout);
//GE_Acc_MikotoBaniere
// TEST APP DATA

Loading…
Cancel
Save