Fixed 64 bit support
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
#include "matrix.h"
|
||||
#include "node.h"
|
||||
#include "quat.h"
|
||||
#include "readwrite.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -126,6 +127,27 @@ osgDB::RegisterReaderWriterProxy<ReaderWriter3DS> g_readerWriter_3DS_Proxy;
|
||||
|
||||
ReaderWriter3DS::ReaderWriter3DS()
|
||||
{
|
||||
setByteOrder();
|
||||
|
||||
#if 0
|
||||
osg::notify(osg::NOTICE)<<"3DS reader sizes:"<<std::endl;
|
||||
osg::notify(osg::NOTICE)<<" sizeof(Lib3dsBool)="<<sizeof(Lib3dsBool)<<std::endl;
|
||||
osg::notify(osg::NOTICE)<<" sizeof(Lib3dsByte)="<<sizeof(Lib3dsByte)<<std::endl;
|
||||
osg::notify(osg::NOTICE)<<" sizeof(Lib3dsWord)="<<sizeof(Lib3dsWord)<<std::endl;
|
||||
osg::notify(osg::NOTICE)<<" sizeof(Lib3dsDword)="<<sizeof(Lib3dsDword)<<std::endl;
|
||||
osg::notify(osg::NOTICE)<<" sizeof(Lib3dsIntb)="<<sizeof(Lib3dsIntb)<<std::endl;
|
||||
osg::notify(osg::NOTICE)<<" sizeof(Lib3dsIntw)="<<sizeof(Lib3dsIntw)<<std::endl;
|
||||
osg::notify(osg::NOTICE)<<" sizeof(Lib3dsIntd)="<<sizeof(Lib3dsIntd)<<std::endl;
|
||||
osg::notify(osg::NOTICE)<<" sizeof(Lib3dsFloat)="<<sizeof(Lib3dsFloat)<<std::endl;
|
||||
osg::notify(osg::NOTICE)<<" sizeof(Lib3dsDouble)="<<sizeof(Lib3dsDouble)<<std::endl;
|
||||
osg::notify(osg::NOTICE)<<" sizeof(Lib3dsVector)="<<sizeof(Lib3dsVector)<<std::endl;
|
||||
osg::notify(osg::NOTICE)<<" sizeof(Lib3dsTexel)="<<sizeof(Lib3dsTexel)<<std::endl;
|
||||
osg::notify(osg::NOTICE)<<" sizeof(Lib3dsQuat)="<<sizeof(Lib3dsQuat)<<std::endl;
|
||||
osg::notify(osg::NOTICE)<<" sizeof(Lib3dsMatrix)="<<sizeof(Lib3dsMatrix)<<std::endl;
|
||||
osg::notify(osg::NOTICE)<<" sizeof(Lib3dsRgb)="<<sizeof(Lib3dsRgb)<<std::endl;
|
||||
osg::notify(osg::NOTICE)<<" sizeof(Lib3dsRgba)="<<sizeof(Lib3dsRgba)<<std::endl;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
ReaderWriter3DS::ReaderObject::ReaderObject()
|
||||
@@ -417,6 +439,7 @@ osg::Node* ReaderWriter3DS::ReaderObject::processNode(StateSetMap drawStateMap,L
|
||||
|
||||
osgDB::ReaderWriter::ReadResult ReaderWriter3DS::readNode(const std::string& file, const osgDB::ReaderWriter::Options* options) const
|
||||
{
|
||||
|
||||
std::string ext = osgDB::getLowerCaseFileExtension(file);
|
||||
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
@@ -446,18 +469,18 @@ osgDB::ReaderWriter::ReadResult ReaderWriter3DS::readNode(const std::string& fil
|
||||
drawStateMap[mat->name] = reader.createStateSet(mat, options);
|
||||
}
|
||||
|
||||
/*{
|
||||
if (osg::getNotifyLevel()>=osg::INFO)
|
||||
{
|
||||
int level=0;
|
||||
std::cout << "NODE TRAVERSAL of file "<<f->name<<std::endl;
|
||||
std::cout << "NODE TRAVERSAL of 3ds file "<<f->name<<std::endl;
|
||||
for(Lib3dsNode *node=f->nodes; node; node=node->next) {
|
||||
print(node,level+1);
|
||||
}
|
||||
std::cout << "MESH TRAVERSAL of file "<<f->name<<std::endl;
|
||||
std::cout << "MESH TRAVERSAL of 3ds file "<<f->name<<std::endl;
|
||||
for(Lib3dsMesh *mesh=f->meshes; mesh; mesh=mesh->next) {
|
||||
print(mesh,level+1);
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
// We can traverse by meshes (old method, broken for pivot points, but otherwise works), or by nodes (new method, not so well tested yet)
|
||||
// if your model is broken, especially wrt object positions try setting this flag. If that fixes it,
|
||||
@@ -481,11 +504,12 @@ osgDB::ReaderWriter::ReadResult ReaderWriter3DS::readNode(const std::string& fil
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*cout << "Final OSG node structure looks like this:"<< endl;
|
||||
PrintVisitor pv;
|
||||
group->accept(pv);*/
|
||||
|
||||
; if (osg::getNotifyLevel()>=osg::INFO)
|
||||
{
|
||||
osg::notify(osg::NOTICE) << "Final OSG node structure looks like this:"<< endl;
|
||||
PrintVisitor pv(osg::notify(osg::NOTICE));
|
||||
group->accept(pv);
|
||||
}
|
||||
|
||||
lib3ds_file_free(f);
|
||||
|
||||
@@ -639,8 +663,10 @@ osg::Drawable* ReaderWriter3DS::ReaderObject::createDrawable(Lib3dsMesh *m,Fac
|
||||
|
||||
geom->addPrimitiveSet(elements);
|
||||
|
||||
#if 0
|
||||
osgUtil::TriStripVisitor tsv;
|
||||
tsv.stripify(*geom);
|
||||
#endif
|
||||
|
||||
return geom;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ static void
|
||||
lib3ds_chunk_debug_dump(Lib3dsChunk *c)
|
||||
{
|
||||
if (enable_dump) {
|
||||
printf("%s%s (0x%X) size=%lu\n",
|
||||
printf("%s%s (0x%X) size=%u\n",
|
||||
lib3ds_chunk_level,
|
||||
lib3ds_chunk_name(c->chunk),
|
||||
c->chunk,
|
||||
|
||||
@@ -495,7 +495,7 @@ lib3ds_mesh_dump(Lib3dsMesh *mesh)
|
||||
Lib3dsVector p;
|
||||
|
||||
ASSERT(mesh);
|
||||
printf(" %s vertices=%ld faces=%ld\n",
|
||||
printf(" %s vertices=%d faces=%d\n",
|
||||
mesh->name,
|
||||
mesh->points,
|
||||
mesh->faces
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
*/
|
||||
#define LIB3DS_EXPORT
|
||||
#include "readwrite.h"
|
||||
|
||||
#include <osg/Endian>
|
||||
|
||||
/*!
|
||||
* \defgroup readwrite Portable Binary Input/Ouput
|
||||
@@ -30,6 +30,15 @@
|
||||
*/
|
||||
|
||||
|
||||
static bool s_requiresByteSwap = false;
|
||||
|
||||
extern LIB3DSAPI void setByteOrder()
|
||||
{
|
||||
s_requiresByteSwap = osg::getCpuByteOrder()==osg::BigEndian;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
* \ingroup readwrite
|
||||
*
|
||||
@@ -129,13 +138,16 @@ Lib3dsIntw
|
||||
lib3ds_intw_read(FILE *f)
|
||||
{
|
||||
Lib3dsByte b[2];
|
||||
Lib3dsWord w;
|
||||
|
||||
ASSERT(f);
|
||||
fread(b,2,1,f);
|
||||
w=((Lib3dsWord)b[1] << 8) |
|
||||
((Lib3dsWord)b[0]);
|
||||
return((Lib3dsIntw)w);
|
||||
|
||||
if (s_requiresByteSwap)
|
||||
{
|
||||
osg::swapBytes2((char*)b);
|
||||
}
|
||||
|
||||
return (*((Lib3dsIntw*)b));
|
||||
}
|
||||
|
||||
|
||||
@@ -152,15 +164,16 @@ Lib3dsIntd
|
||||
lib3ds_intd_read(FILE *f)
|
||||
{
|
||||
Lib3dsByte b[4];
|
||||
Lib3dsDword d;
|
||||
|
||||
ASSERT(f);
|
||||
fread(b,4,1,f);
|
||||
d=((Lib3dsDword)b[3] << 24) |
|
||||
((Lib3dsDword)b[2] << 16) |
|
||||
((Lib3dsDword)b[1] << 8) |
|
||||
((Lib3dsDword)b[0]);
|
||||
return((Lib3dsIntd)d);
|
||||
|
||||
if (s_requiresByteSwap)
|
||||
{
|
||||
osg::swapBytes4((char*)b);
|
||||
}
|
||||
|
||||
return (*((Lib3dsIntd*)b));
|
||||
}
|
||||
|
||||
|
||||
@@ -177,15 +190,16 @@ Lib3dsFloat
|
||||
lib3ds_float_read(FILE *f)
|
||||
{
|
||||
Lib3dsByte b[4];
|
||||
Lib3dsDword d;
|
||||
|
||||
ASSERT(f);
|
||||
fread(b,4,1,f);
|
||||
d=((Lib3dsDword)b[3] << 24) |
|
||||
((Lib3dsDword)b[2] << 16) |
|
||||
((Lib3dsDword)b[1] << 8) |
|
||||
((Lib3dsDword)b[0]);
|
||||
return(*((Lib3dsFloat*)&d));
|
||||
|
||||
if (s_requiresByteSwap)
|
||||
{
|
||||
osg::swapBytes4((char*)b);
|
||||
}
|
||||
|
||||
return (*((Lib3dsFloat*)b));
|
||||
}
|
||||
|
||||
|
||||
@@ -210,6 +224,9 @@ lib3ds_vector_read(Lib3dsVector v, FILE *f)
|
||||
if (ferror(f)) {
|
||||
return(LIB3DS_FALSE);
|
||||
}
|
||||
|
||||
/*printf("lib3ds_vector_read %f %f %f\n",v[0],v[1],v[2]);*/
|
||||
|
||||
return(LIB3DS_TRUE);
|
||||
}
|
||||
|
||||
@@ -227,6 +244,8 @@ lib3ds_rgb_read(Lib3dsRgb rgb, FILE *f)
|
||||
if (ferror(f)) {
|
||||
return(LIB3DS_FALSE);
|
||||
}
|
||||
/*printf("lib3ds_rgb_read %f %f %f\n",rgb[0],rgb[1],rgb[2]);*/
|
||||
|
||||
return(LIB3DS_TRUE);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern LIB3DSAPI void setByteOrder();
|
||||
|
||||
extern LIB3DSAPI Lib3dsByte lib3ds_byte_read(FILE *f);
|
||||
extern LIB3DSAPI Lib3dsWord lib3ds_word_read(FILE *f);
|
||||
extern LIB3DSAPI Lib3dsDword lib3ds_dword_read(FILE *f);
|
||||
|
||||
@@ -45,11 +45,11 @@ extern "C" {
|
||||
|
||||
typedef int Lib3dsBool;
|
||||
typedef unsigned char Lib3dsByte;
|
||||
typedef unsigned short int Lib3dsWord;
|
||||
typedef unsigned long Lib3dsDword;
|
||||
typedef unsigned short Lib3dsWord;
|
||||
typedef unsigned int Lib3dsDword;
|
||||
typedef signed char Lib3dsIntb;
|
||||
typedef signed short int Lib3dsIntw;
|
||||
typedef signed long Lib3dsIntd;
|
||||
typedef signed short Lib3dsIntw;
|
||||
typedef signed int Lib3dsIntd;
|
||||
typedef float Lib3dsFloat;
|
||||
typedef double Lib3dsDouble;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user