2009-01-14 04:37:51 -08:00
|
|
|
// Copyright (C) 2002-2009 Nikolaus Gebhardt
|
2007-05-20 11:03:49 -07:00
|
|
|
// This file is part of the "Irrlicht Engine".
|
|
|
|
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
|
|
|
|
2007-09-04 11:51:42 -07:00
|
|
|
#include "IrrCompileConfig.h"
|
|
|
|
|
|
|
|
#ifdef _IRR_COMPILE_WITH_X_LOADER_
|
|
|
|
|
2007-05-20 11:03:49 -07:00
|
|
|
#include "CXMeshFileLoader.h"
|
|
|
|
#include "os.h"
|
2007-09-04 11:51:42 -07:00
|
|
|
|
|
|
|
#include "fast_atof.h"
|
|
|
|
#include "coreutil.h"
|
2008-03-19 02:54:51 -07:00
|
|
|
#include "ISceneManager.h"
|
2007-09-05 06:10:36 -07:00
|
|
|
#include "IVideoDriver.h"
|
2008-01-29 16:17:16 -08:00
|
|
|
#include "IFileSystem.h"
|
2007-09-06 16:20:02 -07:00
|
|
|
#include "IReadFile.h"
|
2007-05-20 11:03:49 -07:00
|
|
|
|
2007-09-10 06:11:47 -07:00
|
|
|
#ifdef _DEBUG
|
2007-09-10 04:31:43 -07:00
|
|
|
#define _XREADER_DEBUG
|
2007-09-10 06:11:47 -07:00
|
|
|
#endif
|
2007-09-10 04:31:43 -07:00
|
|
|
//#define BETTER_MESHBUFFER_SPLITTING_FOR_X
|
|
|
|
|
2007-05-20 11:03:49 -07:00
|
|
|
namespace irr
|
|
|
|
{
|
|
|
|
namespace scene
|
|
|
|
{
|
|
|
|
|
|
|
|
//! Constructor
|
2008-01-29 16:17:16 -08:00
|
|
|
CXMeshFileLoader::CXMeshFileLoader(scene::ISceneManager* smgr, io::IFileSystem* fs)
|
2009-01-14 05:01:20 -08:00
|
|
|
: SceneManager(smgr), FileSystem(fs), AllJoints(0), AnimatedMesh(0),
|
|
|
|
Buffer(0), P(0), End(0), BinaryNumCount(0), Line(0),
|
|
|
|
CurFrame(0), MajorVersion(0), MinorVersion(0), BinaryFormat(false), FloatSize(0)
|
2007-05-20 11:03:49 -07:00
|
|
|
{
|
2008-04-29 13:54:12 -07:00
|
|
|
#ifdef _DEBUG
|
|
|
|
setDebugName("CXMeshFileLoader");
|
|
|
|
#endif
|
2007-05-20 11:03:49 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//! returns true if the file maybe is able to be loaded by this class
|
|
|
|
//! based on the file extension (e.g. ".bsp")
|
Changes in version 1.6, TA
- FileSystem 2.0 SUPER MASTER MAJOR API CHANGE !!!
The FileSystem is know build internally like for e.q the texture-, and the meshloaders.
There exists a known list of ArchiveLoader, which know how to produce a Archive.
The Loaders and the Archive can be attached/detached on runtime.
The FileNames are now stored as core::string<c16>. where c16 is toggled between char/wchar
with the #define flag _IRR_WCHAR_FILESYSTEM, to supported unicode backends (default:off)
I replaced all (const c8* filename) to string references.
Basically the FileSystem is divided into two regions. Native and Virtual.
Native means using the backend OS.
Virtual means only use currently attach IArchives.
Browsing
each FileSystem has it's own workdirectory and it's own methods to
- create a FileTree
- add/remove files & directory ( to be done )
Hint: store a savegame in a zip archive...
basic browsing for all archives is implemented.
Example 21. Quake3Explorer shows this
TODO:
- a file filter should be implemented.
- The IArchive should have a function to create a filetree
for now CFileList is used.
Class Hiarchy:
IArchiveLoader: is able to produce a IFileArchive
- ZipLoader
- PakLoader
- MountPointReader ( formaly known as CUnzipReader )
IFileArchive:
-ZipArchive
-PakArchive
-MountPoint (known as FolderFile)
IFileSystem
- addArchiveLoader
- changed implementation of isALoadableFileExtension in all loaders
to have consistent behavior
- added a parameter to IFileList * createFileList
setFileListSystem
allows to query files in any of the game archives
standard behavior listtype = SYSTEM ( default)
- CLimitReadFile
added multiple file random-access support.
solved problems with mixed compressed & uncompressed files in a zip
TODO:
- Big Big Testing!!
- Linux Version ( minor )
- remove all double loader interfaces where only the filename differs
(IReadFile/const char *filename). This blows up the the interface
- many loaders use their own private filesearching
we should rework this
- there are a lot of helper function ( getAbsolutePath, getFileDir )
which should be adapted to the virtual filesystem
- IrrlichtDevice
added:
virtual bool setGammaRamp( f32 red, f32 green, f32 blue, f32 brightness, f32 contrast ) = 0;
virtual bool getGammaRamp( f32 &red, f32 &green, f32 &blue ) = 0;
and calculating methods to DeviceStub.
implemented in Win32, TODO: other Devices
- irrlicht.h
changed exported irrlicht.dll routines createDevice, createDeviceEx, IdentityMatrix
to extern "C" name mangling.
for easier dynamically loading the irrlicht library and different versions
- ParticleSystem
removed the private (old?,wrong?) interface from the ParticleEffectors
to match the parent class irr::io::IAttributeExchangingObject::deserializeAttributes
TODO:
please test if the serialization works!
- Generic
- vector3d<T>& normalize()
#if 0
f32 length = (f32)(X*X + Y*Y + Z*Z);
if (core::equals(length, 0.f))
return *this;
length = core::reciprocal_squareroot ( (f32)length );
#else
const T length = core::reciprocal_squareroot ( (X*X + Y*Y + Z*Z) );
#endif
Weak checking on zero?!?! just to avoid a sqrt?. mhm, maybe not;-)
added reciprocal_squareroot for f64
- dimension2d
added operator dimension2d<T>& operator=(const dimension2d<U>& other)
to cast between different types
- vector2d
bugfix:
vector2d<T>& operator+=(const dimension2d<T>& other) { X += other.Width; Y += other.Width; return *this; }
to
vector2d<T>& operator+=(const dimension2d<T>& other) { X += other.Width; Y += other.Height; return *this; }
- C3DMeshLoader renamed chunks const u16 to a enum
removing "variable declared but never used warning"
- added a global const identity Material
changed all references *((video::SMaterial*)0) to point to IdentityMaterial
removed warning: "a NULL reference is not allowed"
- modified IRRLICHT_MATH to not support reciprocal stuff
but to use faster float-to-int conversion.
gcc troubles may they are. i'm using intel-compiler..;-)
- core::matrix4
USE_MATRIX_TEST
i tried to optimize the identity-check ( in means of performance)
i didn't succeed so well, so i made a define for the matrix isIdentity -check
for now it's sometimes faster to always calculate versus identity-check
but if there are a lot of scenenodes/ particles one can profit from the
fast_inverse matrix, when no scaling is used. further approvement could
be done on inverse for just tranlastion! ( many static scenenodes are not rotated,
they are just placed somewhere in the world)
one thing to take in account is that sizeof(matrix) is 64 byte and
with the additional bool/u32 makes it 66 byte which is not really cache-friendly..
- added buildRotateFromTo
Builds a matrix that rotates from one vector to another
- irr::array. changed allocating routine in push_back
okt, 2008. it's only allowed to alloc one element, if
default constructor has to be called.
removes existing crashes. ( MD3 Mesh ) and possible others ones.
A new list template should be made.
one with constructor/destructor calls ( safe_array ) and
one without. like the array since the beginning of irrlicht.
currently the array/string is extremly slow..
also a hint for the user has to be done, so that a struct T of
array<T> must have a copy constructor of type T ( const T&other ).
i needed hours to track that down...
added a new method setAllocStrategy,
safe ( used + 1 ), double ( used * 2 + 1)
better default strategies will be implemented
- removed binary_search_const
i added it quite a long time ago, but it doesnt make real sense
a call to a sort method should happen always. i just wanted to safe
a few cycles..
- added binary_search_multi
searches for a multi-set ( more than 1 entry in the sorted array)
returns start and end-index
- changed some identity matrix settings to use core::IdentityMatrix
- added deletePathFromFilename to generic string functions in coreutil.h and
removed from CZipReader and CPakReader
- s32 deserializeAttributes used instead of virtual void deserializeAttributes in
ParticleSystem ( wrong virtual was used)
- strings & Locale
- started to add locale support
- added verify to string
- added some helper functions
- XBOX
i have access to a XBOX development machine now. I started to compile
for the XBOX. Question: Who did the previous implementation?. There
is no XBOX-Device inhere. maybe it's forbidden because of using the offical
Microsoft XDK. I will implement a native or sdl device based on opendk.
irrlicht compiles without errors on the xbox but can't be used.
TODO:
- native XBOX Device
- Windows Mobile
reworked a little. added the mobile example to the windows solution for
cross development.
added maximal 128x128 texture size for windows mobile ( memory issues )
- Collision Speed Up
The Collision Speed Up greatly improves with many small static child-nodes
- added COctTreeTriangleSelector::getTriangles for 3dline from user Piraaate
- modified createOctTreeTriangleSelector and createTriangleSelector
to allow node == 0, to be added to a meta selector
- CSceneNodeAnimatorCollisionResponse has the same problem as CSceneNodeAnimatorFPS
on first update:
Problem. you start setting the map. (setWorld). First update cames 4000 ms later.
The Animator applies the missing force... big problem...
changed to react on first update like camera.
- add Variable FirstUpdate. if set to true ( on all changes )
then position, lasttime, and falling are initialized
-added #define OCTTREE_USE_HARDWARE in Octree.h
if defined octtree uses internally a derived scene::MeshBuffer which has
the possibility to use the Hardware Vertex Buffer for static vertices and
dirty indices;-)
if defined OCTTREE_USE_HARDWARE octree uses internally a derived scene::CMeshBuffer
so it's not just a replacement inside the octree. It also in the OctTreeSceneNode.
#if defined (OCTTREE_USE_HARDWARE)
driver->drawMeshBuffer ( &LightMapMeshes[i] );
#else
driver->drawIndexedTriangleList( &LightMapMeshes[i].Vertices[0], LightMapMeshes[i].Vertices.size(),
d[i].Indices, d[i].CurrentSize / 3);
#endif
#define OCTTREE_PARENTTEST is also used. It's skip testing on fully outside and takes everything on fully inside
- virtual void ISceneNode::updateAbsolutePosition()
- changed
inline CMatrix4<T> CMatrix4<T>::operator*(const CMatrix4<T>& m2) const
all two matrices have to be checked by isIdentity()
to let the isIdentity work always
-changed inline bool CMatrix4<T>::isIdentity() const
on full identityCheck->
to look first on Translation, because this is the most challenging element
which will likely not to be identity..
- virtual core::matrix4 getRelativeTransformation() const
Hiarchy on Identity-Check
1) ->getRelativeTransform -> 9 floating point checks to be passed as Identity
2) ->isIdentity () -> 16 floating point checks to be passed as Identity
- inline void CMatrix4<T>::transformBoxEx(core::aabbox3d<f32>& box) const
added isIdentity() check
- changed CSceneNodeAnimatorCollisionResponse
- added CSceneNodeAnimatorCollisionResponse::setGravity
needed to set the differents Forces for the Animator. for eq. water..
- added CSceneNodeAnimatorCollisionResponse::setAnimateTarget
- added CSceneNodeAnimatorCollisionResponse::getAnimateTarget
- changed CSceneNodeAnimatorCollisionResponse::animateNode to react on FirstUpdate
- changad Gravity to
- TODO: set Gravity to Physically frame independent values..
current response uses an frame depdended acceleration vector.
~9.81 m/s^2 was achieved at around 50 fps with a setting of -0.03
may effect existing application..
- SceneNodes
- CSkyDomeSceneNode
moved radius ( default 1000 ) to constructor
added Normals
added DebugInfo
added Material.ZBuffer, added SceneMaanager
- CVolumeLightSceneNode:
changed default blending OneTextureBlendgl_src_color gl_src_alpha to
EMT_TRANSPARENT_ADD_COLOR ( gl_src_color gl_one )
which gives the same effect on non-transparent-materials.
Following the unspoken guide-line, lowest effect as default
- added LensFlareSceneNode (from forum user gammaray, modified to work )
showing in example special fx
- changed SceneNode Skydome f64 to f32,
- AnimatedMesh
-Debug Data:
mesh normals didn't rotate with the scenenode fixed ( matrix-multiplication order)
- Camera SceneNode setPosition
Camera now finally allow to change position and target and updates all
effected animators..
a call to OnAnimate ( ) lastime < time or OnAnimate ( 0 ) will reset the
camera and fr. the collision animator to a new position
- Device:
added the current mousebutton state to the Mouse Event
so i need to get the current mouse state from the OS
-a dded to CIrrDeviceWin32
TODO:
- Linux and SDL Device
- GUI
- CGUIFont:
- added virtual void setInvisibleCharacters( const wchar_t *s ) = 0;
define which characters should not be drawn ( send to driver) by the font.
for example " " would not draw any space which is usually blank in most fonts
and saves rendering of ususally full blank alpha-sprites.
This saves a lot of rendering...
default:
setInvisibleCharacters ( L" " );
- added MultiLine rendering
should avoid to us CStaticText breaking text in future
- CGUIListBox
- changed Scrollbar LargeStepSize to ItemHeight
which easy enables to scroll line by line
- CGUIScrollBar
bug:
Create a Window and inside a listbox with a scrollbar or
a windowed irrlicht application
Click & hold Scrollbar Slider. move outside it's region.
Release Mouse. Go Back to Scrollbar.. it's moving always...
it's generally missing the event PRESSED_MOVED, which
leads to problem when an element is dragging, has a focus, or position loose
and gets focus back again. ( think of a drunken mouse sliding left&right during tracking )
so added the mouse Input Buttonstates on every mouse event
IrrDeviceWin32:
added event.MouseInput.ButtonStates = wParam & ( MK_LBUTTON | MK_RBUTTON | MK_MBUTTON );
TODO:
Linux & SDL
so now i can do this
case irr::EMIE_MOUSE_MOVED:
if ( !event.MouseInput.isLeftPressed () )
{
Dragging = false;
}
- bug:
Scrollbar notifyListBox notify when the scrollbar is clicked.
- changed timed event in draw to OnPostRender
Why the hell is a gui element firing a timed event
in a draw routine!!!!!. This should be corrected for all gui-elements.
- added GUI Image List from Reinhard Ostermeier, modified to work
added GUI Tree View from Reinhard Ostermeier, modified to work
shown in the Quake3MapShader Example
TODO: Spritebanks
- FileOpenDialog
changed the static text for the filename to an edit box.
- changed the interface for addEditBox to match with addStaticText
- changed the interface for addSpinBox to match with addEditBox
- added MouseWheel to Spinbox
- changed CGUITable CLICK_AREA from 3 to 12 to enable clicking on the visible marker
- CGUISpritebank
removed some crashes with empty Sprite banks
- IGUIScrollBar
added SetMin before min was always 0
changed ScrollWheel Direction on horizontal to move right on wheel up, left on wheel down
- IComboBox
-added ItemData
- removed IsVisbile check in IGUIElement::draw
- Image Loaders
- added TGA file type 2 ( grayscale uncompressed )
- added TGA file type (1) 8 Bit indexed color uncompressed
ColorConverter:
- added convert_B8G8R8toA8R8G8B8
- added convert_B8G8R8A8toA8R8G8B8
- Media Files
- added missing shaders and textures to map-20kdm2.
Taken from free implementation
- ball.wav. adjusted DC-Offset, amplified to -4dB, trim cross-zero
- impact.wav clip-restoration, trim cross-zero
- added gun.md2, gun.pcx to media-files
copyright issues!. i don't know from where this file came from...
i hope this is not from original quake2..
- added new irrlicht logo irrlicht3.png
i've taken the new layout. i should ask niko to use it.
- added Skydome picture to media files (skydome2.jpg) half/sphere
- OctTree
-added
#define OCTTREE_PARENTTEST ( default: disabled )
used to leave-out children test if the parent passed a complete frustum.
plus: leaves out children test
minus: all edges have to be checked
- added MesBuffer Hardware Hint Vertex to octtree
- CQuake3ShaderSceneNode:
- removed function releaseMesh
Shader doesn't copy the original mesh anymore ( saving memory )
so therefore this (for others often misleading ) function was removed
- changed constructor to take a (shared) destination meshbuffer for rendering
reducing vertex-memory to a half
- don't copy the original vertices anymore
- added deformvertexes autosprite
- added deformvertexes move
- added support for RTCW and Raven BSPs ( qmap2 )
- added polygonoffset (TODO: not perfect)
- added added nomipmaps
- added rgbgen const
- added alphagen
- added MesBuffer Hardware Hint Vertex/Index to Quake3: static geometry, dynamic indices
- added Quake3Explorer examples
- added wave noise
- added tcmod transform
- added whiteimage
- added collision to Quake3Explorer
- renamed SMD3QuaterionTag* to SMD3QuaternionTag* ( typo )
- updated quake3:blendfunc
- added crouch to Quake3Explorer
(modifying the ellipsiodRadius of the camera animator )
added crouch to CSceneNodeAnimatorCameraFPS
still problems with stand up and collision
- Quake3MapLoader
modified memory allocation for faster loading
- Quake3LoadParam
added Parameter to the Mesh-Loader
- added
The still existing missing caulking of curved surfaces.
using round in the coordinates doesn't solve the problem.
but for the demo bsp mesh it solves the problem... (luck)
so for now it's switchable.
TJUNCTION_SOLVER_ROUND
default:off
- BurningVideo
- pushed BurningsVideo to 0.40
- added blendfunc gl_one_minus_dst_alpha gl_one
- added blendfunc gl_dst_color gl_zero
- added blendfunc gl_dst_color src_alpha
- modified AlphaChannel_Ref renderer to support alpha test lessequal
- addded 32 Bit Index Buffer
- added sourceRect/destRect check to 2D-Blitter ( slower, but resolves crash )
- added setTextureCreationFlag video::ETCF_ALLOW_NON_POWER_2
Burning checks this flag and when set, it bypasses the power2 size check,
which is necessary on 3D but can be avoided on 2D.
used on fonts automatically.
- added Support for Destination Alpha
- OpenGL
- Fixed a bug in COpenGLExtensenionHandler where a glint was downcasted to u8!!!!!!
MaxTextureSize=static_cast<u32>(num);
- TODO: COpenGLMaterialRenderer_ONETEXTURE_BLEND to work as expected
- Direct3D8
- compile and links again
- added 32 Bit Index Buffer
- D3DSAMP_MIPMAPLODBIAS doesnt compile!. it is d3d9 i think.
- compile for XBOX
- Direc3D9
- fixed crash on RTT Textures DepthBuffer freed twice.
added deleteAllTextures to destuctor
- NullDriver
- removeallTextures. added setMaterial ( SMaterial() ) to clean pointers for freed textures
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2147 dfc29bdd-3216-0410-991c-e03cc46cb475
2009-01-27 07:53:53 -08:00
|
|
|
bool CXMeshFileLoader::isALoadableFileExtension(const core::string<c16>& filename) const
|
2007-05-20 11:03:49 -07:00
|
|
|
{
|
Changes in version 1.6, TA
- FileSystem 2.0 SUPER MASTER MAJOR API CHANGE !!!
The FileSystem is know build internally like for e.q the texture-, and the meshloaders.
There exists a known list of ArchiveLoader, which know how to produce a Archive.
The Loaders and the Archive can be attached/detached on runtime.
The FileNames are now stored as core::string<c16>. where c16 is toggled between char/wchar
with the #define flag _IRR_WCHAR_FILESYSTEM, to supported unicode backends (default:off)
I replaced all (const c8* filename) to string references.
Basically the FileSystem is divided into two regions. Native and Virtual.
Native means using the backend OS.
Virtual means only use currently attach IArchives.
Browsing
each FileSystem has it's own workdirectory and it's own methods to
- create a FileTree
- add/remove files & directory ( to be done )
Hint: store a savegame in a zip archive...
basic browsing for all archives is implemented.
Example 21. Quake3Explorer shows this
TODO:
- a file filter should be implemented.
- The IArchive should have a function to create a filetree
for now CFileList is used.
Class Hiarchy:
IArchiveLoader: is able to produce a IFileArchive
- ZipLoader
- PakLoader
- MountPointReader ( formaly known as CUnzipReader )
IFileArchive:
-ZipArchive
-PakArchive
-MountPoint (known as FolderFile)
IFileSystem
- addArchiveLoader
- changed implementation of isALoadableFileExtension in all loaders
to have consistent behavior
- added a parameter to IFileList * createFileList
setFileListSystem
allows to query files in any of the game archives
standard behavior listtype = SYSTEM ( default)
- CLimitReadFile
added multiple file random-access support.
solved problems with mixed compressed & uncompressed files in a zip
TODO:
- Big Big Testing!!
- Linux Version ( minor )
- remove all double loader interfaces where only the filename differs
(IReadFile/const char *filename). This blows up the the interface
- many loaders use their own private filesearching
we should rework this
- there are a lot of helper function ( getAbsolutePath, getFileDir )
which should be adapted to the virtual filesystem
- IrrlichtDevice
added:
virtual bool setGammaRamp( f32 red, f32 green, f32 blue, f32 brightness, f32 contrast ) = 0;
virtual bool getGammaRamp( f32 &red, f32 &green, f32 &blue ) = 0;
and calculating methods to DeviceStub.
implemented in Win32, TODO: other Devices
- irrlicht.h
changed exported irrlicht.dll routines createDevice, createDeviceEx, IdentityMatrix
to extern "C" name mangling.
for easier dynamically loading the irrlicht library and different versions
- ParticleSystem
removed the private (old?,wrong?) interface from the ParticleEffectors
to match the parent class irr::io::IAttributeExchangingObject::deserializeAttributes
TODO:
please test if the serialization works!
- Generic
- vector3d<T>& normalize()
#if 0
f32 length = (f32)(X*X + Y*Y + Z*Z);
if (core::equals(length, 0.f))
return *this;
length = core::reciprocal_squareroot ( (f32)length );
#else
const T length = core::reciprocal_squareroot ( (X*X + Y*Y + Z*Z) );
#endif
Weak checking on zero?!?! just to avoid a sqrt?. mhm, maybe not;-)
added reciprocal_squareroot for f64
- dimension2d
added operator dimension2d<T>& operator=(const dimension2d<U>& other)
to cast between different types
- vector2d
bugfix:
vector2d<T>& operator+=(const dimension2d<T>& other) { X += other.Width; Y += other.Width; return *this; }
to
vector2d<T>& operator+=(const dimension2d<T>& other) { X += other.Width; Y += other.Height; return *this; }
- C3DMeshLoader renamed chunks const u16 to a enum
removing "variable declared but never used warning"
- added a global const identity Material
changed all references *((video::SMaterial*)0) to point to IdentityMaterial
removed warning: "a NULL reference is not allowed"
- modified IRRLICHT_MATH to not support reciprocal stuff
but to use faster float-to-int conversion.
gcc troubles may they are. i'm using intel-compiler..;-)
- core::matrix4
USE_MATRIX_TEST
i tried to optimize the identity-check ( in means of performance)
i didn't succeed so well, so i made a define for the matrix isIdentity -check
for now it's sometimes faster to always calculate versus identity-check
but if there are a lot of scenenodes/ particles one can profit from the
fast_inverse matrix, when no scaling is used. further approvement could
be done on inverse for just tranlastion! ( many static scenenodes are not rotated,
they are just placed somewhere in the world)
one thing to take in account is that sizeof(matrix) is 64 byte and
with the additional bool/u32 makes it 66 byte which is not really cache-friendly..
- added buildRotateFromTo
Builds a matrix that rotates from one vector to another
- irr::array. changed allocating routine in push_back
okt, 2008. it's only allowed to alloc one element, if
default constructor has to be called.
removes existing crashes. ( MD3 Mesh ) and possible others ones.
A new list template should be made.
one with constructor/destructor calls ( safe_array ) and
one without. like the array since the beginning of irrlicht.
currently the array/string is extremly slow..
also a hint for the user has to be done, so that a struct T of
array<T> must have a copy constructor of type T ( const T&other ).
i needed hours to track that down...
added a new method setAllocStrategy,
safe ( used + 1 ), double ( used * 2 + 1)
better default strategies will be implemented
- removed binary_search_const
i added it quite a long time ago, but it doesnt make real sense
a call to a sort method should happen always. i just wanted to safe
a few cycles..
- added binary_search_multi
searches for a multi-set ( more than 1 entry in the sorted array)
returns start and end-index
- changed some identity matrix settings to use core::IdentityMatrix
- added deletePathFromFilename to generic string functions in coreutil.h and
removed from CZipReader and CPakReader
- s32 deserializeAttributes used instead of virtual void deserializeAttributes in
ParticleSystem ( wrong virtual was used)
- strings & Locale
- started to add locale support
- added verify to string
- added some helper functions
- XBOX
i have access to a XBOX development machine now. I started to compile
for the XBOX. Question: Who did the previous implementation?. There
is no XBOX-Device inhere. maybe it's forbidden because of using the offical
Microsoft XDK. I will implement a native or sdl device based on opendk.
irrlicht compiles without errors on the xbox but can't be used.
TODO:
- native XBOX Device
- Windows Mobile
reworked a little. added the mobile example to the windows solution for
cross development.
added maximal 128x128 texture size for windows mobile ( memory issues )
- Collision Speed Up
The Collision Speed Up greatly improves with many small static child-nodes
- added COctTreeTriangleSelector::getTriangles for 3dline from user Piraaate
- modified createOctTreeTriangleSelector and createTriangleSelector
to allow node == 0, to be added to a meta selector
- CSceneNodeAnimatorCollisionResponse has the same problem as CSceneNodeAnimatorFPS
on first update:
Problem. you start setting the map. (setWorld). First update cames 4000 ms later.
The Animator applies the missing force... big problem...
changed to react on first update like camera.
- add Variable FirstUpdate. if set to true ( on all changes )
then position, lasttime, and falling are initialized
-added #define OCTTREE_USE_HARDWARE in Octree.h
if defined octtree uses internally a derived scene::MeshBuffer which has
the possibility to use the Hardware Vertex Buffer for static vertices and
dirty indices;-)
if defined OCTTREE_USE_HARDWARE octree uses internally a derived scene::CMeshBuffer
so it's not just a replacement inside the octree. It also in the OctTreeSceneNode.
#if defined (OCTTREE_USE_HARDWARE)
driver->drawMeshBuffer ( &LightMapMeshes[i] );
#else
driver->drawIndexedTriangleList( &LightMapMeshes[i].Vertices[0], LightMapMeshes[i].Vertices.size(),
d[i].Indices, d[i].CurrentSize / 3);
#endif
#define OCTTREE_PARENTTEST is also used. It's skip testing on fully outside and takes everything on fully inside
- virtual void ISceneNode::updateAbsolutePosition()
- changed
inline CMatrix4<T> CMatrix4<T>::operator*(const CMatrix4<T>& m2) const
all two matrices have to be checked by isIdentity()
to let the isIdentity work always
-changed inline bool CMatrix4<T>::isIdentity() const
on full identityCheck->
to look first on Translation, because this is the most challenging element
which will likely not to be identity..
- virtual core::matrix4 getRelativeTransformation() const
Hiarchy on Identity-Check
1) ->getRelativeTransform -> 9 floating point checks to be passed as Identity
2) ->isIdentity () -> 16 floating point checks to be passed as Identity
- inline void CMatrix4<T>::transformBoxEx(core::aabbox3d<f32>& box) const
added isIdentity() check
- changed CSceneNodeAnimatorCollisionResponse
- added CSceneNodeAnimatorCollisionResponse::setGravity
needed to set the differents Forces for the Animator. for eq. water..
- added CSceneNodeAnimatorCollisionResponse::setAnimateTarget
- added CSceneNodeAnimatorCollisionResponse::getAnimateTarget
- changed CSceneNodeAnimatorCollisionResponse::animateNode to react on FirstUpdate
- changad Gravity to
- TODO: set Gravity to Physically frame independent values..
current response uses an frame depdended acceleration vector.
~9.81 m/s^2 was achieved at around 50 fps with a setting of -0.03
may effect existing application..
- SceneNodes
- CSkyDomeSceneNode
moved radius ( default 1000 ) to constructor
added Normals
added DebugInfo
added Material.ZBuffer, added SceneMaanager
- CVolumeLightSceneNode:
changed default blending OneTextureBlendgl_src_color gl_src_alpha to
EMT_TRANSPARENT_ADD_COLOR ( gl_src_color gl_one )
which gives the same effect on non-transparent-materials.
Following the unspoken guide-line, lowest effect as default
- added LensFlareSceneNode (from forum user gammaray, modified to work )
showing in example special fx
- changed SceneNode Skydome f64 to f32,
- AnimatedMesh
-Debug Data:
mesh normals didn't rotate with the scenenode fixed ( matrix-multiplication order)
- Camera SceneNode setPosition
Camera now finally allow to change position and target and updates all
effected animators..
a call to OnAnimate ( ) lastime < time or OnAnimate ( 0 ) will reset the
camera and fr. the collision animator to a new position
- Device:
added the current mousebutton state to the Mouse Event
so i need to get the current mouse state from the OS
-a dded to CIrrDeviceWin32
TODO:
- Linux and SDL Device
- GUI
- CGUIFont:
- added virtual void setInvisibleCharacters( const wchar_t *s ) = 0;
define which characters should not be drawn ( send to driver) by the font.
for example " " would not draw any space which is usually blank in most fonts
and saves rendering of ususally full blank alpha-sprites.
This saves a lot of rendering...
default:
setInvisibleCharacters ( L" " );
- added MultiLine rendering
should avoid to us CStaticText breaking text in future
- CGUIListBox
- changed Scrollbar LargeStepSize to ItemHeight
which easy enables to scroll line by line
- CGUIScrollBar
bug:
Create a Window and inside a listbox with a scrollbar or
a windowed irrlicht application
Click & hold Scrollbar Slider. move outside it's region.
Release Mouse. Go Back to Scrollbar.. it's moving always...
it's generally missing the event PRESSED_MOVED, which
leads to problem when an element is dragging, has a focus, or position loose
and gets focus back again. ( think of a drunken mouse sliding left&right during tracking )
so added the mouse Input Buttonstates on every mouse event
IrrDeviceWin32:
added event.MouseInput.ButtonStates = wParam & ( MK_LBUTTON | MK_RBUTTON | MK_MBUTTON );
TODO:
Linux & SDL
so now i can do this
case irr::EMIE_MOUSE_MOVED:
if ( !event.MouseInput.isLeftPressed () )
{
Dragging = false;
}
- bug:
Scrollbar notifyListBox notify when the scrollbar is clicked.
- changed timed event in draw to OnPostRender
Why the hell is a gui element firing a timed event
in a draw routine!!!!!. This should be corrected for all gui-elements.
- added GUI Image List from Reinhard Ostermeier, modified to work
added GUI Tree View from Reinhard Ostermeier, modified to work
shown in the Quake3MapShader Example
TODO: Spritebanks
- FileOpenDialog
changed the static text for the filename to an edit box.
- changed the interface for addEditBox to match with addStaticText
- changed the interface for addSpinBox to match with addEditBox
- added MouseWheel to Spinbox
- changed CGUITable CLICK_AREA from 3 to 12 to enable clicking on the visible marker
- CGUISpritebank
removed some crashes with empty Sprite banks
- IGUIScrollBar
added SetMin before min was always 0
changed ScrollWheel Direction on horizontal to move right on wheel up, left on wheel down
- IComboBox
-added ItemData
- removed IsVisbile check in IGUIElement::draw
- Image Loaders
- added TGA file type 2 ( grayscale uncompressed )
- added TGA file type (1) 8 Bit indexed color uncompressed
ColorConverter:
- added convert_B8G8R8toA8R8G8B8
- added convert_B8G8R8A8toA8R8G8B8
- Media Files
- added missing shaders and textures to map-20kdm2.
Taken from free implementation
- ball.wav. adjusted DC-Offset, amplified to -4dB, trim cross-zero
- impact.wav clip-restoration, trim cross-zero
- added gun.md2, gun.pcx to media-files
copyright issues!. i don't know from where this file came from...
i hope this is not from original quake2..
- added new irrlicht logo irrlicht3.png
i've taken the new layout. i should ask niko to use it.
- added Skydome picture to media files (skydome2.jpg) half/sphere
- OctTree
-added
#define OCTTREE_PARENTTEST ( default: disabled )
used to leave-out children test if the parent passed a complete frustum.
plus: leaves out children test
minus: all edges have to be checked
- added MesBuffer Hardware Hint Vertex to octtree
- CQuake3ShaderSceneNode:
- removed function releaseMesh
Shader doesn't copy the original mesh anymore ( saving memory )
so therefore this (for others often misleading ) function was removed
- changed constructor to take a (shared) destination meshbuffer for rendering
reducing vertex-memory to a half
- don't copy the original vertices anymore
- added deformvertexes autosprite
- added deformvertexes move
- added support for RTCW and Raven BSPs ( qmap2 )
- added polygonoffset (TODO: not perfect)
- added added nomipmaps
- added rgbgen const
- added alphagen
- added MesBuffer Hardware Hint Vertex/Index to Quake3: static geometry, dynamic indices
- added Quake3Explorer examples
- added wave noise
- added tcmod transform
- added whiteimage
- added collision to Quake3Explorer
- renamed SMD3QuaterionTag* to SMD3QuaternionTag* ( typo )
- updated quake3:blendfunc
- added crouch to Quake3Explorer
(modifying the ellipsiodRadius of the camera animator )
added crouch to CSceneNodeAnimatorCameraFPS
still problems with stand up and collision
- Quake3MapLoader
modified memory allocation for faster loading
- Quake3LoadParam
added Parameter to the Mesh-Loader
- added
The still existing missing caulking of curved surfaces.
using round in the coordinates doesn't solve the problem.
but for the demo bsp mesh it solves the problem... (luck)
so for now it's switchable.
TJUNCTION_SOLVER_ROUND
default:off
- BurningVideo
- pushed BurningsVideo to 0.40
- added blendfunc gl_one_minus_dst_alpha gl_one
- added blendfunc gl_dst_color gl_zero
- added blendfunc gl_dst_color src_alpha
- modified AlphaChannel_Ref renderer to support alpha test lessequal
- addded 32 Bit Index Buffer
- added sourceRect/destRect check to 2D-Blitter ( slower, but resolves crash )
- added setTextureCreationFlag video::ETCF_ALLOW_NON_POWER_2
Burning checks this flag and when set, it bypasses the power2 size check,
which is necessary on 3D but can be avoided on 2D.
used on fonts automatically.
- added Support for Destination Alpha
- OpenGL
- Fixed a bug in COpenGLExtensenionHandler where a glint was downcasted to u8!!!!!!
MaxTextureSize=static_cast<u32>(num);
- TODO: COpenGLMaterialRenderer_ONETEXTURE_BLEND to work as expected
- Direct3D8
- compile and links again
- added 32 Bit Index Buffer
- D3DSAMP_MIPMAPLODBIAS doesnt compile!. it is d3d9 i think.
- compile for XBOX
- Direc3D9
- fixed crash on RTT Textures DepthBuffer freed twice.
added deleteAllTextures to destuctor
- NullDriver
- removeallTextures. added setMaterial ( SMaterial() ) to clean pointers for freed textures
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2147 dfc29bdd-3216-0410-991c-e03cc46cb475
2009-01-27 07:53:53 -08:00
|
|
|
return core::hasFileExtension ( filename, "x" );
|
2007-05-20 11:03:49 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//! creates/loads an animated mesh from the file.
|
|
|
|
//! \return Pointer to the created mesh. Returns 0 if loading failed.
|
|
|
|
//! If you no longer need the mesh, you should call IAnimatedMesh::drop().
|
2007-09-06 23:11:47 -07:00
|
|
|
//! See IReferenceCounted::drop() for more information.
|
2007-09-19 07:08:28 -07:00
|
|
|
IAnimatedMesh* CXMeshFileLoader::createMesh(io::IReadFile* f)
|
2007-05-20 11:03:49 -07:00
|
|
|
{
|
2007-09-04 11:51:42 -07:00
|
|
|
if (!f)
|
2007-05-20 11:03:49 -07:00
|
|
|
return 0;
|
|
|
|
|
2008-02-21 05:03:22 -08:00
|
|
|
#ifdef _XREADER_DEBUG
|
2007-09-14 17:55:30 -07:00
|
|
|
u32 time = os::Timer::getRealTime();
|
2008-02-21 05:03:22 -08:00
|
|
|
#endif
|
2007-09-14 17:55:30 -07:00
|
|
|
|
2007-09-04 11:51:42 -07:00
|
|
|
AnimatedMesh = new CSkinnedMesh();
|
2007-05-20 11:03:49 -07:00
|
|
|
|
2008-10-25 14:22:35 -07:00
|
|
|
if (load(f))
|
2007-05-20 11:03:49 -07:00
|
|
|
{
|
2007-09-04 11:51:42 -07:00
|
|
|
AnimatedMesh->finalize();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
AnimatedMesh->drop();
|
|
|
|
AnimatedMesh = 0;
|
2007-05-20 11:03:49 -07:00
|
|
|
}
|
2007-09-14 17:55:30 -07:00
|
|
|
#ifdef _XREADER_DEBUG
|
|
|
|
time = os::Timer::getRealTime() - time;
|
|
|
|
core::stringc tmpString = "Time to load ";
|
|
|
|
tmpString += BinaryFormat ? "binary" : "ascii";
|
|
|
|
tmpString += " X file: ";
|
|
|
|
tmpString += time;
|
|
|
|
tmpString += "ms";
|
|
|
|
os::Printer::log(tmpString.c_str());
|
|
|
|
#endif
|
2007-09-04 11:51:42 -07:00
|
|
|
//Clear up
|
2007-05-20 11:03:49 -07:00
|
|
|
|
2007-09-04 11:51:42 -07:00
|
|
|
MajorVersion=0;
|
|
|
|
MinorVersion=0;
|
2007-09-06 16:20:02 -07:00
|
|
|
BinaryFormat=0;
|
|
|
|
BinaryNumCount=0;
|
2007-09-04 11:51:42 -07:00
|
|
|
FloatSize=0;
|
|
|
|
P=0;
|
|
|
|
End=0;
|
|
|
|
CurFrame=0;
|
|
|
|
TemplateMaterials.clear();
|
|
|
|
|
2007-09-27 09:04:03 -07:00
|
|
|
delete [] Buffer;
|
2007-09-06 05:38:06 -07:00
|
|
|
Buffer = 0;
|
|
|
|
|
|
|
|
for (u32 i=0; i<Meshes.size(); ++i)
|
|
|
|
delete Meshes[i];
|
2007-09-04 11:51:42 -07:00
|
|
|
Meshes.clear();
|
|
|
|
|
|
|
|
return AnimatedMesh;
|
2007-05-20 11:03:49 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-06 16:20:02 -07:00
|
|
|
bool CXMeshFileLoader::load(io::IReadFile* file)
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
2007-09-06 16:20:02 -07:00
|
|
|
if (!readFileIntoMemory(file))
|
2007-09-04 11:51:42 -07:00
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!parseFile())
|
|
|
|
return false;
|
|
|
|
|
2007-09-06 16:20:02 -07:00
|
|
|
for (u32 n=0; n<Meshes.size(); ++n)
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
2007-09-06 16:20:02 -07:00
|
|
|
SXMesh *mesh=Meshes[n];
|
2007-09-04 11:51:42 -07:00
|
|
|
|
2007-09-06 16:20:02 -07:00
|
|
|
// default material if nothing loaded
|
|
|
|
if (!mesh->Materials.size())
|
2009-01-09 14:36:10 -08:00
|
|
|
{
|
2007-09-06 16:20:02 -07:00
|
|
|
mesh->Materials.push_back(video::SMaterial());
|
2009-01-09 14:36:10 -08:00
|
|
|
mesh->Materials[0].DiffuseColor.set(0xff777777);
|
|
|
|
mesh->Materials[0].Shininess=0.f;
|
|
|
|
mesh->Materials[0].SpecularColor.set(0xff777777);
|
|
|
|
mesh->Materials[0].EmissiveColor.set(0xff000000);
|
|
|
|
}
|
2007-09-04 11:51:42 -07:00
|
|
|
|
|
|
|
u32 i;
|
|
|
|
|
2007-09-10 06:11:47 -07:00
|
|
|
mesh->Buffers.reallocate(mesh->Materials.size());
|
2008-02-07 06:54:04 -08:00
|
|
|
#ifndef BETTER_MESHBUFFER_SPLITTING_FOR_X
|
2007-09-18 05:00:03 -07:00
|
|
|
const u32 bufferOffset = AnimatedMesh->getMeshBufferCount();
|
2008-02-07 06:54:04 -08:00
|
|
|
#endif
|
2007-09-06 16:20:02 -07:00
|
|
|
for (i=0; i<mesh->Materials.size(); ++i)
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
2007-09-06 16:20:02 -07:00
|
|
|
mesh->Buffers.push_back( AnimatedMesh->createBuffer() );
|
|
|
|
mesh->Buffers.getLast()->Material = mesh->Materials[i];
|
2007-09-04 11:51:42 -07:00
|
|
|
|
2007-09-17 04:09:07 -07:00
|
|
|
if (!mesh->HasSkinning)
|
|
|
|
{
|
|
|
|
//Set up rigid animation
|
|
|
|
if (mesh->AttachedJointID!=-1)
|
|
|
|
{
|
|
|
|
AnimatedMesh->getAllJoints()[mesh->AttachedJointID]->AttachedMeshes.push_back( AnimatedMesh->getMeshBuffers().size()-1 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-09-04 11:51:42 -07:00
|
|
|
|
2009-01-09 14:30:10 -08:00
|
|
|
if (!mesh->FaceMaterialIndices.size())
|
|
|
|
{
|
|
|
|
mesh->FaceMaterialIndices.set_used(mesh->Indices.size() / 3);
|
|
|
|
for (i=0; i<mesh->FaceMaterialIndices.size(); ++i)
|
|
|
|
mesh->FaceMaterialIndices[i]=0;
|
|
|
|
}
|
|
|
|
|
2007-09-18 05:00:03 -07:00
|
|
|
if (!mesh->HasVertexColors)
|
|
|
|
{
|
|
|
|
for (u32 j=0;j<mesh->FaceMaterialIndices.size();++j)
|
|
|
|
{
|
|
|
|
for (u32 id=j*3+0;id<=j*3+2;++id)
|
|
|
|
{
|
|
|
|
mesh->Vertices[ mesh->Indices[id] ].Color = mesh->Buffers[mesh->FaceMaterialIndices[j]]->Material.DiffuseColor;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-04 11:51:42 -07:00
|
|
|
#ifdef BETTER_MESHBUFFER_SPLITTING_FOR_X
|
2007-09-06 16:20:02 -07:00
|
|
|
{
|
2007-09-04 11:51:42 -07:00
|
|
|
//the same vertex can be used in many different meshbuffers, but it's slow to work out
|
|
|
|
|
2007-09-18 05:00:03 -07:00
|
|
|
core::array< core::array< u32 > > verticesLinkIndex;
|
|
|
|
verticesLinkIndex.reallocate(mesh->Vertices.size());
|
|
|
|
core::array< core::array< u16 > > verticesLinkBuffer;
|
2007-09-07 07:18:47 -07:00
|
|
|
verticesLinkBuffer.reallocate(mesh->Vertices.size());
|
2007-09-10 06:11:47 -07:00
|
|
|
|
2007-09-07 07:18:47 -07:00
|
|
|
for (i=0;i<mesh->Vertices.size();++i)
|
|
|
|
{
|
2007-09-18 05:00:03 -07:00
|
|
|
verticesLinkIndex.push_back( core::array< u32 >() );
|
|
|
|
verticesLinkBuffer.push_back( core::array< u16 >() );
|
2007-09-07 07:18:47 -07:00
|
|
|
}
|
2007-09-04 11:51:42 -07:00
|
|
|
|
2007-09-07 07:18:47 -07:00
|
|
|
for (i=0;i<mesh->FaceMaterialIndices.size();++i)
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
|
|
|
for (u32 id=i*3+0;id<=i*3+2;++id)
|
|
|
|
{
|
2008-01-13 16:23:02 -08:00
|
|
|
core::array< u16 > &Array=verticesLinkBuffer[ mesh->Indices[id] ];
|
2007-09-04 11:51:42 -07:00
|
|
|
bool found=false;
|
|
|
|
|
2007-09-06 09:14:33 -07:00
|
|
|
for (u32 j=0; j < Array.size(); ++j)
|
|
|
|
{
|
2007-09-07 07:18:47 -07:00
|
|
|
if (Array[j]==mesh->FaceMaterialIndices[i])
|
2007-09-06 09:14:33 -07:00
|
|
|
{
|
|
|
|
found=true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2007-09-04 11:51:42 -07:00
|
|
|
|
|
|
|
if (!found)
|
2007-09-07 07:18:47 -07:00
|
|
|
Array.push_back( mesh->FaceMaterialIndices[i] );
|
2007-09-04 11:51:42 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-06 16:20:02 -07:00
|
|
|
for (i=0;i<verticesLinkBuffer.size();++i)
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
2007-09-06 16:20:02 -07:00
|
|
|
if (!verticesLinkBuffer[i].size())
|
|
|
|
verticesLinkBuffer[i].push_back(0);
|
2007-09-04 11:51:42 -07:00
|
|
|
}
|
|
|
|
|
2007-09-06 16:20:02 -07:00
|
|
|
for (i=0;i<mesh->Vertices.size();++i)
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
2007-09-18 05:00:03 -07:00
|
|
|
core::array< u16 > &Array = verticesLinkBuffer[i];
|
|
|
|
verticesLinkIndex[i].reallocate(Array.size());
|
2007-09-06 16:20:02 -07:00
|
|
|
for (u32 j=0; j < Array.size(); ++j)
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
2007-09-06 16:20:02 -07:00
|
|
|
scene::SSkinMeshBuffer *buffer = mesh->Buffers[ Array[j] ];
|
2007-09-18 05:00:03 -07:00
|
|
|
verticesLinkIndex[i].push_back( buffer->Vertices_Standard.size() );
|
2007-09-06 16:20:02 -07:00
|
|
|
buffer->Vertices_Standard.push_back( mesh->Vertices[i] );
|
2007-09-04 11:51:42 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-07 07:18:47 -07:00
|
|
|
for (i=0;i<mesh->FaceMaterialIndices.size();++i)
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
2007-09-07 07:18:47 -07:00
|
|
|
scene::SSkinMeshBuffer *buffer=mesh->Buffers[ mesh->FaceMaterialIndices[i] ];
|
2007-09-04 11:51:42 -07:00
|
|
|
|
|
|
|
for (u32 id=i*3+0;id<=i*3+2;++id)
|
|
|
|
{
|
2007-09-18 05:00:03 -07:00
|
|
|
core::array< u16 > &Array=verticesLinkBuffer[ mesh->Indices[id] ];
|
2007-09-04 11:51:42 -07:00
|
|
|
|
2008-02-07 06:54:04 -08:00
|
|
|
for (u32 j=0;j< Array.size() ;++j)
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
2007-09-07 07:18:47 -07:00
|
|
|
if ( Array[j]== mesh->FaceMaterialIndices[i] )
|
2007-09-18 05:00:03 -07:00
|
|
|
buffer->Indices.push_back( verticesLinkIndex[ mesh->Indices[id] ][j] );
|
2007-09-04 11:51:42 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-13 16:23:02 -08:00
|
|
|
for (u32 j=0;j<mesh->WeightJoint.size();++j)
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
2008-02-07 06:54:04 -08:00
|
|
|
ISkinnedMesh::SJoint* joint = AnimatedMesh->getAllJoints()[mesh->WeightJoint[j]];
|
|
|
|
ISkinnedMesh::SWeight& weight = joint->Weights[mesh->WeightNum[j]];
|
2007-09-04 11:51:42 -07:00
|
|
|
|
2008-01-13 16:23:02 -08:00
|
|
|
u32 id = weight.vertex_id;
|
2007-09-04 11:51:42 -07:00
|
|
|
|
2007-09-18 05:00:03 -07:00
|
|
|
if (id>=verticesLinkIndex.size())
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
2007-09-17 19:51:06 -07:00
|
|
|
os::Printer::log("X loader: Weight id out of range", ELL_WARNING);
|
|
|
|
id=0;
|
2008-01-13 16:23:02 -08:00
|
|
|
weight.strength=0.f;
|
2007-09-17 19:51:06 -07:00
|
|
|
}
|
2007-09-04 11:51:42 -07:00
|
|
|
|
2007-09-17 19:51:06 -07:00
|
|
|
if (verticesLinkBuffer[id].size()==1)
|
|
|
|
{
|
2008-01-13 16:23:02 -08:00
|
|
|
weight.vertex_id=verticesLinkIndex[id][0];
|
|
|
|
weight.buffer_id=verticesLinkBuffer[id][0];
|
2007-09-17 19:51:06 -07:00
|
|
|
}
|
|
|
|
else if (verticesLinkBuffer[id].size() != 0)
|
|
|
|
{
|
|
|
|
for (u32 k=1; k < verticesLinkBuffer[id].size(); ++k)
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
2008-01-13 16:23:02 -08:00
|
|
|
ISkinnedMesh::SWeight* WeightClone = AnimatedMesh->createWeight(joint);
|
|
|
|
WeightClone->strength = weight.strength;
|
2007-09-18 05:00:03 -07:00
|
|
|
WeightClone->vertex_id = verticesLinkIndex[id][k];
|
2007-09-17 19:51:06 -07:00
|
|
|
WeightClone->buffer_id = verticesLinkBuffer[id][k];
|
2007-09-04 11:51:42 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-09-06 16:20:02 -07:00
|
|
|
}
|
2007-09-04 11:51:42 -07:00
|
|
|
#else
|
2007-09-06 16:20:02 -07:00
|
|
|
{
|
2007-09-18 05:00:03 -07:00
|
|
|
core::array< u32 > verticesLinkIndex;
|
2008-02-07 06:54:04 -08:00
|
|
|
core::array< s16 > verticesLinkBuffer;
|
2007-09-06 16:20:02 -07:00
|
|
|
verticesLinkBuffer.set_used(mesh->Vertices.size());
|
2007-09-04 11:51:42 -07:00
|
|
|
|
2007-09-06 16:20:02 -07:00
|
|
|
// init with 0
|
|
|
|
for (i=0;i<mesh->Vertices.size();++i)
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
2008-02-07 06:54:04 -08:00
|
|
|
verticesLinkBuffer[i]=-1;
|
2007-09-04 11:51:42 -07:00
|
|
|
}
|
|
|
|
|
2008-02-07 06:54:04 -08:00
|
|
|
bool warned = false;
|
2007-09-07 09:09:14 -07:00
|
|
|
// store meshbuffer number per vertex
|
2007-09-07 07:18:47 -07:00
|
|
|
for (i=0;i<mesh->FaceMaterialIndices.size();++i)
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
|
|
|
for (u32 id=i*3+0;id<=i*3+2;++id)
|
|
|
|
{
|
2008-10-25 14:22:35 -07:00
|
|
|
if ((verticesLinkBuffer[mesh->Indices[id]] != -1) && (verticesLinkBuffer[mesh->Indices[id]] != (s16)mesh->FaceMaterialIndices[i]))
|
2008-02-07 06:54:04 -08:00
|
|
|
{
|
|
|
|
if (!warned)
|
|
|
|
{
|
|
|
|
os::Printer::log("X loader", "Duplicated vertex, animation might be corrupted.", ELL_WARNING);
|
|
|
|
warned=true;
|
|
|
|
}
|
|
|
|
const u32 tmp = mesh->Vertices.size();
|
|
|
|
mesh->Vertices.push_back(mesh->Vertices[ mesh->Indices[id] ]);
|
|
|
|
mesh->Indices[id] = tmp;
|
|
|
|
verticesLinkBuffer.set_used(mesh->Vertices.size());
|
|
|
|
}
|
2007-09-07 07:18:47 -07:00
|
|
|
verticesLinkBuffer[ mesh->Indices[id] ] = mesh->FaceMaterialIndices[i];
|
2007-09-04 11:51:42 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-04 01:43:08 -07:00
|
|
|
if (mesh->FaceMaterialIndices.size() != 0)
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
2008-04-04 01:43:08 -07:00
|
|
|
// store vertices in buffers and remember relation in verticesLinkIndex
|
|
|
|
u32* vCountArray = new u32[mesh->Buffers.size()];
|
|
|
|
memset(vCountArray, 0, mesh->Buffers.size()*sizeof(u32));
|
|
|
|
// count vertices in each buffer and reallocate
|
2008-10-25 14:22:35 -07:00
|
|
|
for (i=0; i<mesh->Vertices.size(); ++i)
|
2008-04-04 01:43:08 -07:00
|
|
|
++vCountArray[verticesLinkBuffer[i]];
|
2008-12-13 15:09:39 -08:00
|
|
|
if (mesh->TCoords2.size())
|
|
|
|
{
|
|
|
|
for (i=0; i!=mesh->Buffers.size(); ++i)
|
|
|
|
{
|
|
|
|
mesh->Buffers[i]->Vertices_2TCoords.reallocate(vCountArray[i]);
|
|
|
|
mesh->Buffers[i]->VertexType=video::EVT_2TCOORDS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (i=0; i!=mesh->Buffers.size(); ++i)
|
|
|
|
mesh->Buffers[i]->Vertices_Standard.reallocate(vCountArray[i]);
|
|
|
|
}
|
2008-04-04 01:43:08 -07:00
|
|
|
|
|
|
|
verticesLinkIndex.set_used(mesh->Vertices.size());
|
|
|
|
// actually store vertices
|
2008-10-25 14:22:35 -07:00
|
|
|
for (i=0; i<mesh->Vertices.size(); ++i)
|
2008-04-04 01:43:08 -07:00
|
|
|
{
|
|
|
|
scene::SSkinMeshBuffer *buffer = mesh->Buffers[ verticesLinkBuffer[i] ];
|
2007-09-04 11:51:42 -07:00
|
|
|
|
2008-12-13 15:09:39 -08:00
|
|
|
if (mesh->TCoords2.size())
|
|
|
|
{
|
|
|
|
verticesLinkIndex[i] = buffer->Vertices_2TCoords.size();
|
|
|
|
buffer->Vertices_2TCoords.push_back( mesh->Vertices[i] );
|
|
|
|
buffer->Vertices_2TCoords.getLast().TCoords2=mesh->TCoords2[i];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
verticesLinkIndex[i] = buffer->Vertices_Standard.size();
|
|
|
|
buffer->Vertices_Standard.push_back( mesh->Vertices[i] );
|
|
|
|
}
|
2008-04-04 01:43:08 -07:00
|
|
|
}
|
2007-09-04 11:51:42 -07:00
|
|
|
|
2008-04-04 01:43:08 -07:00
|
|
|
// count indices per buffer and reallocate
|
|
|
|
memset(vCountArray, 0, mesh->Buffers.size()*sizeof(u32));
|
2008-10-25 14:22:35 -07:00
|
|
|
for (i=0; i<mesh->FaceMaterialIndices.size(); ++i)
|
2008-04-04 01:43:08 -07:00
|
|
|
++vCountArray[ mesh->FaceMaterialIndices[i] ];
|
|
|
|
for (i=0; i!=mesh->Buffers.size(); ++i)
|
|
|
|
mesh->Buffers[i]->Indices.reallocate(vCountArray[i]);
|
|
|
|
delete [] vCountArray;
|
|
|
|
// create indices per buffer
|
2008-10-25 14:22:35 -07:00
|
|
|
for (i=0; i<mesh->FaceMaterialIndices.size(); ++i)
|
2008-02-07 06:54:04 -08:00
|
|
|
{
|
2008-04-04 01:43:08 -07:00
|
|
|
scene::SSkinMeshBuffer *buffer = mesh->Buffers[ mesh->FaceMaterialIndices[i] ];
|
2008-10-25 14:22:35 -07:00
|
|
|
for (u32 id=i*3+0; id!=i*3+3; ++id)
|
2008-04-04 01:43:08 -07:00
|
|
|
{
|
|
|
|
buffer->Indices.push_back( verticesLinkIndex[ mesh->Indices[id] ] );
|
|
|
|
}
|
2008-02-07 06:54:04 -08:00
|
|
|
}
|
2007-09-04 11:51:42 -07:00
|
|
|
}
|
|
|
|
|
2008-10-25 14:22:35 -07:00
|
|
|
for (u32 j=0; j<mesh->WeightJoint.size(); ++j)
|
2007-09-17 19:51:06 -07:00
|
|
|
{
|
2008-01-13 16:23:02 -08:00
|
|
|
ISkinnedMesh::SWeight& weight = (AnimatedMesh->getAllJoints()[mesh->WeightJoint[j]]->Weights[mesh->WeightNum[j]]);
|
2007-09-17 04:09:07 -07:00
|
|
|
|
2008-01-13 16:23:02 -08:00
|
|
|
u32 id = weight.vertex_id;
|
2007-09-04 11:51:42 -07:00
|
|
|
|
2007-09-18 05:00:03 -07:00
|
|
|
if (id>=verticesLinkIndex.size())
|
2007-09-17 19:51:06 -07:00
|
|
|
{
|
|
|
|
os::Printer::log("X loader: Weight id out of range", ELL_WARNING);
|
|
|
|
id=0;
|
2008-01-13 16:23:02 -08:00
|
|
|
weight.strength=0.f;
|
2007-09-04 11:51:42 -07:00
|
|
|
}
|
2007-09-17 19:51:06 -07:00
|
|
|
|
2008-01-13 16:23:02 -08:00
|
|
|
weight.vertex_id=verticesLinkIndex[id];
|
2008-02-07 06:54:04 -08:00
|
|
|
weight.buffer_id=verticesLinkBuffer[id] + bufferOffset;
|
2007-09-04 11:51:42 -07:00
|
|
|
}
|
2007-09-06 16:20:02 -07:00
|
|
|
}
|
2007-09-04 11:51:42 -07:00
|
|
|
#endif
|
2007-09-17 04:09:07 -07:00
|
|
|
|
2007-09-04 11:51:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//! Reads file into memory
|
2007-09-06 16:20:02 -07:00
|
|
|
bool CXMeshFileLoader::readFileIntoMemory(io::IReadFile* file)
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
2007-09-14 02:07:11 -07:00
|
|
|
const long size = file->getSize();
|
2007-09-06 16:20:02 -07:00
|
|
|
if (size < 12)
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
|
|
|
os::Printer::log("X File is too small.", ELL_WARNING);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-09-06 16:20:02 -07:00
|
|
|
Buffer = new c8[size];
|
2007-09-04 11:51:42 -07:00
|
|
|
|
|
|
|
//! read all into memory
|
2007-09-06 16:20:02 -07:00
|
|
|
if (file->read(Buffer, size) != size)
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
|
|
|
os::Printer::log("Could not read from x file.", ELL_WARNING);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-10-22 02:23:31 -07:00
|
|
|
Line = 1;
|
2007-09-06 16:20:02 -07:00
|
|
|
End = Buffer + size;
|
2007-09-04 11:51:42 -07:00
|
|
|
|
|
|
|
//! check header "xof "
|
|
|
|
if (strncmp(Buffer, "xof ", 4)!=0)
|
|
|
|
{
|
|
|
|
os::Printer::log("Not an x file, wrong header.", ELL_WARNING);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//! read minor and major version, e.g. 0302 or 0303
|
|
|
|
c8 tmp[3];
|
|
|
|
tmp[2] = 0x0;
|
|
|
|
tmp[0] = Buffer[4];
|
|
|
|
tmp[1] = Buffer[5];
|
2007-09-06 16:20:02 -07:00
|
|
|
MajorVersion = core::strtol10(tmp);
|
2007-09-04 11:51:42 -07:00
|
|
|
|
|
|
|
tmp[0] = Buffer[6];
|
|
|
|
tmp[1] = Buffer[7];
|
2007-09-06 16:20:02 -07:00
|
|
|
MinorVersion = core::strtol10(tmp);
|
2007-09-04 11:51:42 -07:00
|
|
|
|
|
|
|
//! read format
|
|
|
|
if (strncmp(&Buffer[8], "txt ", 4) ==0)
|
2007-09-06 16:20:02 -07:00
|
|
|
BinaryFormat = false;
|
2007-09-04 11:51:42 -07:00
|
|
|
else if (strncmp(&Buffer[8], "bin ", 4) ==0)
|
2007-09-06 16:20:02 -07:00
|
|
|
BinaryFormat = true;
|
2007-09-04 11:51:42 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
os::Printer::log("Only uncompressed x files currently supported.", ELL_WARNING);
|
|
|
|
return false;
|
|
|
|
}
|
2007-09-06 16:20:02 -07:00
|
|
|
BinaryNumCount=0;
|
2007-09-04 11:51:42 -07:00
|
|
|
|
|
|
|
//! read float size
|
|
|
|
if (strncmp(&Buffer[12], "0032", 4) ==0)
|
|
|
|
FloatSize = 4;
|
|
|
|
else if (strncmp(&Buffer[12], "0064", 4) ==0)
|
|
|
|
FloatSize = 8;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
os::Printer::log("Float size not supported.", ELL_WARNING);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
P = &Buffer[16];
|
|
|
|
|
|
|
|
readUntilEndOfLine();
|
Changes in version 1.6, TA
- FileSystem 2.0 SUPER MASTER MAJOR API CHANGE !!!
The FileSystem is know build internally like for e.q the texture-, and the meshloaders.
There exists a known list of ArchiveLoader, which know how to produce a Archive.
The Loaders and the Archive can be attached/detached on runtime.
The FileNames are now stored as core::string<c16>. where c16 is toggled between char/wchar
with the #define flag _IRR_WCHAR_FILESYSTEM, to supported unicode backends (default:off)
I replaced all (const c8* filename) to string references.
Basically the FileSystem is divided into two regions. Native and Virtual.
Native means using the backend OS.
Virtual means only use currently attach IArchives.
Browsing
each FileSystem has it's own workdirectory and it's own methods to
- create a FileTree
- add/remove files & directory ( to be done )
Hint: store a savegame in a zip archive...
basic browsing for all archives is implemented.
Example 21. Quake3Explorer shows this
TODO:
- a file filter should be implemented.
- The IArchive should have a function to create a filetree
for now CFileList is used.
Class Hiarchy:
IArchiveLoader: is able to produce a IFileArchive
- ZipLoader
- PakLoader
- MountPointReader ( formaly known as CUnzipReader )
IFileArchive:
-ZipArchive
-PakArchive
-MountPoint (known as FolderFile)
IFileSystem
- addArchiveLoader
- changed implementation of isALoadableFileExtension in all loaders
to have consistent behavior
- added a parameter to IFileList * createFileList
setFileListSystem
allows to query files in any of the game archives
standard behavior listtype = SYSTEM ( default)
- CLimitReadFile
added multiple file random-access support.
solved problems with mixed compressed & uncompressed files in a zip
TODO:
- Big Big Testing!!
- Linux Version ( minor )
- remove all double loader interfaces where only the filename differs
(IReadFile/const char *filename). This blows up the the interface
- many loaders use their own private filesearching
we should rework this
- there are a lot of helper function ( getAbsolutePath, getFileDir )
which should be adapted to the virtual filesystem
- IrrlichtDevice
added:
virtual bool setGammaRamp( f32 red, f32 green, f32 blue, f32 brightness, f32 contrast ) = 0;
virtual bool getGammaRamp( f32 &red, f32 &green, f32 &blue ) = 0;
and calculating methods to DeviceStub.
implemented in Win32, TODO: other Devices
- irrlicht.h
changed exported irrlicht.dll routines createDevice, createDeviceEx, IdentityMatrix
to extern "C" name mangling.
for easier dynamically loading the irrlicht library and different versions
- ParticleSystem
removed the private (old?,wrong?) interface from the ParticleEffectors
to match the parent class irr::io::IAttributeExchangingObject::deserializeAttributes
TODO:
please test if the serialization works!
- Generic
- vector3d<T>& normalize()
#if 0
f32 length = (f32)(X*X + Y*Y + Z*Z);
if (core::equals(length, 0.f))
return *this;
length = core::reciprocal_squareroot ( (f32)length );
#else
const T length = core::reciprocal_squareroot ( (X*X + Y*Y + Z*Z) );
#endif
Weak checking on zero?!?! just to avoid a sqrt?. mhm, maybe not;-)
added reciprocal_squareroot for f64
- dimension2d
added operator dimension2d<T>& operator=(const dimension2d<U>& other)
to cast between different types
- vector2d
bugfix:
vector2d<T>& operator+=(const dimension2d<T>& other) { X += other.Width; Y += other.Width; return *this; }
to
vector2d<T>& operator+=(const dimension2d<T>& other) { X += other.Width; Y += other.Height; return *this; }
- C3DMeshLoader renamed chunks const u16 to a enum
removing "variable declared but never used warning"
- added a global const identity Material
changed all references *((video::SMaterial*)0) to point to IdentityMaterial
removed warning: "a NULL reference is not allowed"
- modified IRRLICHT_MATH to not support reciprocal stuff
but to use faster float-to-int conversion.
gcc troubles may they are. i'm using intel-compiler..;-)
- core::matrix4
USE_MATRIX_TEST
i tried to optimize the identity-check ( in means of performance)
i didn't succeed so well, so i made a define for the matrix isIdentity -check
for now it's sometimes faster to always calculate versus identity-check
but if there are a lot of scenenodes/ particles one can profit from the
fast_inverse matrix, when no scaling is used. further approvement could
be done on inverse for just tranlastion! ( many static scenenodes are not rotated,
they are just placed somewhere in the world)
one thing to take in account is that sizeof(matrix) is 64 byte and
with the additional bool/u32 makes it 66 byte which is not really cache-friendly..
- added buildRotateFromTo
Builds a matrix that rotates from one vector to another
- irr::array. changed allocating routine in push_back
okt, 2008. it's only allowed to alloc one element, if
default constructor has to be called.
removes existing crashes. ( MD3 Mesh ) and possible others ones.
A new list template should be made.
one with constructor/destructor calls ( safe_array ) and
one without. like the array since the beginning of irrlicht.
currently the array/string is extremly slow..
also a hint for the user has to be done, so that a struct T of
array<T> must have a copy constructor of type T ( const T&other ).
i needed hours to track that down...
added a new method setAllocStrategy,
safe ( used + 1 ), double ( used * 2 + 1)
better default strategies will be implemented
- removed binary_search_const
i added it quite a long time ago, but it doesnt make real sense
a call to a sort method should happen always. i just wanted to safe
a few cycles..
- added binary_search_multi
searches for a multi-set ( more than 1 entry in the sorted array)
returns start and end-index
- changed some identity matrix settings to use core::IdentityMatrix
- added deletePathFromFilename to generic string functions in coreutil.h and
removed from CZipReader and CPakReader
- s32 deserializeAttributes used instead of virtual void deserializeAttributes in
ParticleSystem ( wrong virtual was used)
- strings & Locale
- started to add locale support
- added verify to string
- added some helper functions
- XBOX
i have access to a XBOX development machine now. I started to compile
for the XBOX. Question: Who did the previous implementation?. There
is no XBOX-Device inhere. maybe it's forbidden because of using the offical
Microsoft XDK. I will implement a native or sdl device based on opendk.
irrlicht compiles without errors on the xbox but can't be used.
TODO:
- native XBOX Device
- Windows Mobile
reworked a little. added the mobile example to the windows solution for
cross development.
added maximal 128x128 texture size for windows mobile ( memory issues )
- Collision Speed Up
The Collision Speed Up greatly improves with many small static child-nodes
- added COctTreeTriangleSelector::getTriangles for 3dline from user Piraaate
- modified createOctTreeTriangleSelector and createTriangleSelector
to allow node == 0, to be added to a meta selector
- CSceneNodeAnimatorCollisionResponse has the same problem as CSceneNodeAnimatorFPS
on first update:
Problem. you start setting the map. (setWorld). First update cames 4000 ms later.
The Animator applies the missing force... big problem...
changed to react on first update like camera.
- add Variable FirstUpdate. if set to true ( on all changes )
then position, lasttime, and falling are initialized
-added #define OCTTREE_USE_HARDWARE in Octree.h
if defined octtree uses internally a derived scene::MeshBuffer which has
the possibility to use the Hardware Vertex Buffer for static vertices and
dirty indices;-)
if defined OCTTREE_USE_HARDWARE octree uses internally a derived scene::CMeshBuffer
so it's not just a replacement inside the octree. It also in the OctTreeSceneNode.
#if defined (OCTTREE_USE_HARDWARE)
driver->drawMeshBuffer ( &LightMapMeshes[i] );
#else
driver->drawIndexedTriangleList( &LightMapMeshes[i].Vertices[0], LightMapMeshes[i].Vertices.size(),
d[i].Indices, d[i].CurrentSize / 3);
#endif
#define OCTTREE_PARENTTEST is also used. It's skip testing on fully outside and takes everything on fully inside
- virtual void ISceneNode::updateAbsolutePosition()
- changed
inline CMatrix4<T> CMatrix4<T>::operator*(const CMatrix4<T>& m2) const
all two matrices have to be checked by isIdentity()
to let the isIdentity work always
-changed inline bool CMatrix4<T>::isIdentity() const
on full identityCheck->
to look first on Translation, because this is the most challenging element
which will likely not to be identity..
- virtual core::matrix4 getRelativeTransformation() const
Hiarchy on Identity-Check
1) ->getRelativeTransform -> 9 floating point checks to be passed as Identity
2) ->isIdentity () -> 16 floating point checks to be passed as Identity
- inline void CMatrix4<T>::transformBoxEx(core::aabbox3d<f32>& box) const
added isIdentity() check
- changed CSceneNodeAnimatorCollisionResponse
- added CSceneNodeAnimatorCollisionResponse::setGravity
needed to set the differents Forces for the Animator. for eq. water..
- added CSceneNodeAnimatorCollisionResponse::setAnimateTarget
- added CSceneNodeAnimatorCollisionResponse::getAnimateTarget
- changed CSceneNodeAnimatorCollisionResponse::animateNode to react on FirstUpdate
- changad Gravity to
- TODO: set Gravity to Physically frame independent values..
current response uses an frame depdended acceleration vector.
~9.81 m/s^2 was achieved at around 50 fps with a setting of -0.03
may effect existing application..
- SceneNodes
- CSkyDomeSceneNode
moved radius ( default 1000 ) to constructor
added Normals
added DebugInfo
added Material.ZBuffer, added SceneMaanager
- CVolumeLightSceneNode:
changed default blending OneTextureBlendgl_src_color gl_src_alpha to
EMT_TRANSPARENT_ADD_COLOR ( gl_src_color gl_one )
which gives the same effect on non-transparent-materials.
Following the unspoken guide-line, lowest effect as default
- added LensFlareSceneNode (from forum user gammaray, modified to work )
showing in example special fx
- changed SceneNode Skydome f64 to f32,
- AnimatedMesh
-Debug Data:
mesh normals didn't rotate with the scenenode fixed ( matrix-multiplication order)
- Camera SceneNode setPosition
Camera now finally allow to change position and target and updates all
effected animators..
a call to OnAnimate ( ) lastime < time or OnAnimate ( 0 ) will reset the
camera and fr. the collision animator to a new position
- Device:
added the current mousebutton state to the Mouse Event
so i need to get the current mouse state from the OS
-a dded to CIrrDeviceWin32
TODO:
- Linux and SDL Device
- GUI
- CGUIFont:
- added virtual void setInvisibleCharacters( const wchar_t *s ) = 0;
define which characters should not be drawn ( send to driver) by the font.
for example " " would not draw any space which is usually blank in most fonts
and saves rendering of ususally full blank alpha-sprites.
This saves a lot of rendering...
default:
setInvisibleCharacters ( L" " );
- added MultiLine rendering
should avoid to us CStaticText breaking text in future
- CGUIListBox
- changed Scrollbar LargeStepSize to ItemHeight
which easy enables to scroll line by line
- CGUIScrollBar
bug:
Create a Window and inside a listbox with a scrollbar or
a windowed irrlicht application
Click & hold Scrollbar Slider. move outside it's region.
Release Mouse. Go Back to Scrollbar.. it's moving always...
it's generally missing the event PRESSED_MOVED, which
leads to problem when an element is dragging, has a focus, or position loose
and gets focus back again. ( think of a drunken mouse sliding left&right during tracking )
so added the mouse Input Buttonstates on every mouse event
IrrDeviceWin32:
added event.MouseInput.ButtonStates = wParam & ( MK_LBUTTON | MK_RBUTTON | MK_MBUTTON );
TODO:
Linux & SDL
so now i can do this
case irr::EMIE_MOUSE_MOVED:
if ( !event.MouseInput.isLeftPressed () )
{
Dragging = false;
}
- bug:
Scrollbar notifyListBox notify when the scrollbar is clicked.
- changed timed event in draw to OnPostRender
Why the hell is a gui element firing a timed event
in a draw routine!!!!!. This should be corrected for all gui-elements.
- added GUI Image List from Reinhard Ostermeier, modified to work
added GUI Tree View from Reinhard Ostermeier, modified to work
shown in the Quake3MapShader Example
TODO: Spritebanks
- FileOpenDialog
changed the static text for the filename to an edit box.
- changed the interface for addEditBox to match with addStaticText
- changed the interface for addSpinBox to match with addEditBox
- added MouseWheel to Spinbox
- changed CGUITable CLICK_AREA from 3 to 12 to enable clicking on the visible marker
- CGUISpritebank
removed some crashes with empty Sprite banks
- IGUIScrollBar
added SetMin before min was always 0
changed ScrollWheel Direction on horizontal to move right on wheel up, left on wheel down
- IComboBox
-added ItemData
- removed IsVisbile check in IGUIElement::draw
- Image Loaders
- added TGA file type 2 ( grayscale uncompressed )
- added TGA file type (1) 8 Bit indexed color uncompressed
ColorConverter:
- added convert_B8G8R8toA8R8G8B8
- added convert_B8G8R8A8toA8R8G8B8
- Media Files
- added missing shaders and textures to map-20kdm2.
Taken from free implementation
- ball.wav. adjusted DC-Offset, amplified to -4dB, trim cross-zero
- impact.wav clip-restoration, trim cross-zero
- added gun.md2, gun.pcx to media-files
copyright issues!. i don't know from where this file came from...
i hope this is not from original quake2..
- added new irrlicht logo irrlicht3.png
i've taken the new layout. i should ask niko to use it.
- added Skydome picture to media files (skydome2.jpg) half/sphere
- OctTree
-added
#define OCTTREE_PARENTTEST ( default: disabled )
used to leave-out children test if the parent passed a complete frustum.
plus: leaves out children test
minus: all edges have to be checked
- added MesBuffer Hardware Hint Vertex to octtree
- CQuake3ShaderSceneNode:
- removed function releaseMesh
Shader doesn't copy the original mesh anymore ( saving memory )
so therefore this (for others often misleading ) function was removed
- changed constructor to take a (shared) destination meshbuffer for rendering
reducing vertex-memory to a half
- don't copy the original vertices anymore
- added deformvertexes autosprite
- added deformvertexes move
- added support for RTCW and Raven BSPs ( qmap2 )
- added polygonoffset (TODO: not perfect)
- added added nomipmaps
- added rgbgen const
- added alphagen
- added MesBuffer Hardware Hint Vertex/Index to Quake3: static geometry, dynamic indices
- added Quake3Explorer examples
- added wave noise
- added tcmod transform
- added whiteimage
- added collision to Quake3Explorer
- renamed SMD3QuaterionTag* to SMD3QuaternionTag* ( typo )
- updated quake3:blendfunc
- added crouch to Quake3Explorer
(modifying the ellipsiodRadius of the camera animator )
added crouch to CSceneNodeAnimatorCameraFPS
still problems with stand up and collision
- Quake3MapLoader
modified memory allocation for faster loading
- Quake3LoadParam
added Parameter to the Mesh-Loader
- added
The still existing missing caulking of curved surfaces.
using round in the coordinates doesn't solve the problem.
but for the demo bsp mesh it solves the problem... (luck)
so for now it's switchable.
TJUNCTION_SOLVER_ROUND
default:off
- BurningVideo
- pushed BurningsVideo to 0.40
- added blendfunc gl_one_minus_dst_alpha gl_one
- added blendfunc gl_dst_color gl_zero
- added blendfunc gl_dst_color src_alpha
- modified AlphaChannel_Ref renderer to support alpha test lessequal
- addded 32 Bit Index Buffer
- added sourceRect/destRect check to 2D-Blitter ( slower, but resolves crash )
- added setTextureCreationFlag video::ETCF_ALLOW_NON_POWER_2
Burning checks this flag and when set, it bypasses the power2 size check,
which is necessary on 3D but can be avoided on 2D.
used on fonts automatically.
- added Support for Destination Alpha
- OpenGL
- Fixed a bug in COpenGLExtensenionHandler where a glint was downcasted to u8!!!!!!
MaxTextureSize=static_cast<u32>(num);
- TODO: COpenGLMaterialRenderer_ONETEXTURE_BLEND to work as expected
- Direct3D8
- compile and links again
- added 32 Bit Index Buffer
- D3DSAMP_MIPMAPLODBIAS doesnt compile!. it is d3d9 i think.
- compile for XBOX
- Direc3D9
- fixed crash on RTT Textures DepthBuffer freed twice.
added deleteAllTextures to destuctor
- NullDriver
- removeallTextures. added setMaterial ( SMaterial() ) to clean pointers for freed textures
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2147 dfc29bdd-3216-0410-991c-e03cc46cb475
2009-01-27 07:53:53 -08:00
|
|
|
FilePath = FileSystem->getFileDir(file->getFileName()) + "/";
|
2009-01-14 10:01:51 -08:00
|
|
|
FilePath += '/';
|
2007-09-04 11:51:42 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//! Parses the file
|
|
|
|
bool CXMeshFileLoader::parseFile()
|
|
|
|
{
|
|
|
|
while(parseDataObject())
|
|
|
|
{
|
|
|
|
// loop
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//! Parses the next Data object in the file
|
|
|
|
bool CXMeshFileLoader::parseDataObject()
|
|
|
|
{
|
|
|
|
core::stringc objectName = getNextToken();
|
|
|
|
|
|
|
|
if (objectName.size() == 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// parse specific object
|
2007-09-10 04:31:43 -07:00
|
|
|
#ifdef _XREADER_DEBUG
|
2007-09-04 11:51:42 -07:00
|
|
|
os::Printer::log("debug DataObject:", objectName.c_str() );
|
2007-09-04 15:23:51 -07:00
|
|
|
#endif
|
2007-09-04 11:51:42 -07:00
|
|
|
|
|
|
|
if (objectName == "template")
|
|
|
|
return parseDataObjectTemplate();
|
|
|
|
else
|
|
|
|
if (objectName == "Frame")
|
|
|
|
{
|
|
|
|
return parseDataObjectFrame( 0 );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (objectName == "Mesh")
|
|
|
|
{
|
|
|
|
// some meshes have no frames at all
|
|
|
|
//CurFrame = AnimatedMesh->createJoint(0);
|
|
|
|
|
2007-09-06 16:20:02 -07:00
|
|
|
SXMesh *mesh=new SXMesh;
|
2007-09-04 11:51:42 -07:00
|
|
|
|
2007-09-06 16:20:02 -07:00
|
|
|
//mesh->Buffer=AnimatedMesh->createBuffer();
|
|
|
|
Meshes.push_back(mesh);
|
2007-09-04 11:51:42 -07:00
|
|
|
|
2008-10-25 14:22:35 -07:00
|
|
|
return parseDataObjectMesh(*mesh);
|
2007-09-04 11:51:42 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
if (objectName == "AnimationSet")
|
|
|
|
{
|
|
|
|
return parseDataObjectAnimationSet();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (objectName == "Material")
|
|
|
|
{
|
|
|
|
// template materials now available thanks to joeWright
|
|
|
|
TemplateMaterials.push_back(SXTemplateMaterial());
|
|
|
|
TemplateMaterials.getLast().Name = getNextToken();
|
|
|
|
return parseDataObjectMaterial(TemplateMaterials.getLast().Material);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (objectName == "}")
|
|
|
|
{
|
2007-09-05 01:59:46 -07:00
|
|
|
os::Printer::log("} found in dataObject", ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-09-10 09:15:36 -07:00
|
|
|
os::Printer::log("Unknown data object in animation of .x file", objectName.c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
|
|
|
|
return parseUnknownDataObject();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CXMeshFileLoader::parseDataObjectTemplate()
|
|
|
|
{
|
|
|
|
#ifdef _XREADER_DEBUG
|
|
|
|
os::Printer::log("CXFileReader: Reading template");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// parse a template data object. Currently not stored.
|
2007-09-09 16:09:06 -07:00
|
|
|
core::stringc name;
|
2007-09-04 11:51:42 -07:00
|
|
|
|
2007-09-09 16:09:06 -07:00
|
|
|
if (!readHeadOfDataObject(&name))
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
|
|
|
os::Printer::log("Left delimiter in template data object missing.",
|
2009-02-18 13:25:13 -08:00
|
|
|
name.c_str(), ELL_WARNING);
|
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// read GUID
|
2008-02-21 05:03:22 -08:00
|
|
|
getNextToken();
|
2007-09-04 11:51:42 -07:00
|
|
|
|
|
|
|
// read and ignore data members
|
|
|
|
while(true)
|
|
|
|
{
|
|
|
|
core::stringc s = getNextToken();
|
|
|
|
|
|
|
|
if (s == "}")
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (s.size() == 0)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-13 15:09:39 -08:00
|
|
|
bool CXMeshFileLoader::parseDataObjectFrame(CSkinnedMesh::SJoint *Parent)
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
|
|
|
#ifdef _XREADER_DEBUG
|
|
|
|
os::Printer::log("CXFileReader: Reading frame");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// A coordinate frame, or "frame of reference." The Frame template
|
|
|
|
// is open and can contain any object. The Direct3D extensions (D3DX)
|
|
|
|
// mesh-loading functions recognize Mesh, FrameTransformMatrix, and
|
|
|
|
// Frame template instances as child objects when loading a Frame
|
|
|
|
// instance.
|
|
|
|
|
2007-09-17 04:09:07 -07:00
|
|
|
u32 JointID=0;
|
|
|
|
|
2007-09-09 16:09:06 -07:00
|
|
|
core::stringc name;
|
2007-09-04 11:51:42 -07:00
|
|
|
|
2007-09-09 16:09:06 -07:00
|
|
|
if (!readHeadOfDataObject(&name))
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
|
|
|
os::Printer::log("No opening brace in Frame found in x file", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
CSkinnedMesh::SJoint *joint=0;
|
|
|
|
|
2007-09-10 09:15:36 -07:00
|
|
|
if (name.size())
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
2008-10-25 14:22:35 -07:00
|
|
|
for (u32 n=0; n < AnimatedMesh->getAllJoints().size(); ++n)
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
2007-09-09 16:09:06 -07:00
|
|
|
if (AnimatedMesh->getAllJoints()[n]->Name==name)
|
2007-09-10 09:15:36 -07:00
|
|
|
{
|
2007-09-04 11:51:42 -07:00
|
|
|
joint=AnimatedMesh->getAllJoints()[n];
|
2007-09-17 04:09:07 -07:00
|
|
|
JointID=n;
|
2007-09-10 09:15:36 -07:00
|
|
|
break;
|
|
|
|
}
|
2007-09-04 11:51:42 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!joint)
|
|
|
|
{
|
2007-09-10 04:31:43 -07:00
|
|
|
#ifdef _XREADER_DEBUG
|
2007-09-09 16:09:06 -07:00
|
|
|
os::Printer::log("creating joint ", name.c_str());
|
2007-09-05 01:59:46 -07:00
|
|
|
#endif
|
2007-09-04 11:51:42 -07:00
|
|
|
joint=AnimatedMesh->createJoint(Parent);
|
2007-09-09 16:09:06 -07:00
|
|
|
joint->Name=name;
|
2007-09-17 04:09:07 -07:00
|
|
|
JointID=AnimatedMesh->getAllJoints().size()-1;
|
2007-09-04 11:51:42 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-09-10 04:31:43 -07:00
|
|
|
#ifdef _XREADER_DEBUG
|
2007-09-09 16:09:06 -07:00
|
|
|
os::Printer::log("using joint ", name.c_str());
|
2007-09-05 01:59:46 -07:00
|
|
|
#endif
|
2007-09-04 11:51:42 -07:00
|
|
|
if (Parent)
|
|
|
|
Parent->Children.push_back(joint);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now inside a frame.
|
|
|
|
// read tokens until closing brace is reached.
|
|
|
|
|
|
|
|
while(true)
|
|
|
|
{
|
|
|
|
core::stringc objectName = getNextToken();
|
|
|
|
|
2007-09-10 04:31:43 -07:00
|
|
|
#ifdef _XREADER_DEBUG
|
2007-09-04 11:51:42 -07:00
|
|
|
os::Printer::log("debug DataObject in frame:", objectName.c_str() );
|
2007-09-04 15:23:51 -07:00
|
|
|
#endif
|
2007-09-04 11:51:42 -07:00
|
|
|
|
|
|
|
if (objectName.size() == 0)
|
|
|
|
{
|
|
|
|
os::Printer::log("Unexpected ending found in Frame in x file.", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (objectName == "}")
|
|
|
|
{
|
|
|
|
break; // frame finished
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (objectName == "Frame")
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!parseDataObjectFrame(joint))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (objectName == "FrameTransformMatrix")
|
|
|
|
{
|
|
|
|
if (!parseDataObjectTransformationMatrix(joint->LocalMatrix))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
//joint->LocalAnimatedMatrix
|
|
|
|
//joint->LocalAnimatedMatrix.makeInverse();
|
|
|
|
//joint->LocalMatrix=tmp*joint->LocalAnimatedMatrix;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (objectName == "Mesh")
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
frame.Meshes.push_back(SXMesh());
|
|
|
|
if (!parseDataObjectMesh(frame.Meshes.getLast()))
|
|
|
|
return false;
|
|
|
|
*/
|
2007-09-06 16:20:02 -07:00
|
|
|
SXMesh *mesh=new SXMesh;
|
2007-09-04 11:51:42 -07:00
|
|
|
|
2007-09-17 04:09:07 -07:00
|
|
|
mesh->AttachedJointID=JointID;
|
|
|
|
|
2007-09-06 16:20:02 -07:00
|
|
|
Meshes.push_back(mesh);
|
2007-09-04 11:51:42 -07:00
|
|
|
|
2007-09-09 01:39:21 -07:00
|
|
|
if (!parseDataObjectMesh(*mesh))
|
|
|
|
return false;
|
2007-09-04 11:51:42 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-09-05 01:59:46 -07:00
|
|
|
os::Printer::log("Unknown data object in frame in x file", objectName.c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
if (!parseUnknownDataObject())
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CXMeshFileLoader::parseDataObjectTransformationMatrix(core::matrix4 &mat)
|
|
|
|
{
|
|
|
|
#ifdef _XREADER_DEBUG
|
|
|
|
os::Printer::log("CXFileReader: Reading Transformation Matrix");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!readHeadOfDataObject())
|
|
|
|
{
|
|
|
|
os::Printer::log("No opening brace in Transformation Matrix found in x file", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-02-12 07:32:39 -08:00
|
|
|
readMatrix(mat);
|
2007-09-04 11:51:42 -07:00
|
|
|
|
2008-02-12 07:32:39 -08:00
|
|
|
if (!checkForOneFollowingSemicolons())
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
|
|
|
os::Printer::log("No finishing semicolon in Transformation Matrix found in x file", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
}
|
|
|
|
|
2007-09-10 09:15:36 -07:00
|
|
|
if (!checkForClosingBrace())
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
|
|
|
os::Printer::log("No closing brace in Transformation Matrix found in x file", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CXMeshFileLoader::parseDataObjectMesh(SXMesh &mesh)
|
|
|
|
{
|
|
|
|
core::stringc name;
|
|
|
|
|
|
|
|
if (!readHeadOfDataObject(&name))
|
|
|
|
{
|
2008-10-01 04:36:20 -07:00
|
|
|
#ifdef _XREADER_DEBUG
|
|
|
|
os::Printer::log("CXFileReader: Reading mesh");
|
|
|
|
#endif
|
2007-09-04 11:51:42 -07:00
|
|
|
os::Printer::log("No opening brace in Mesh found in x file", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-10-01 04:36:20 -07:00
|
|
|
#ifdef _XREADER_DEBUG
|
|
|
|
os::Printer::log("CXFileReader: Reading mesh", name.c_str());
|
|
|
|
#endif
|
|
|
|
|
2007-09-04 11:51:42 -07:00
|
|
|
// read vertex count
|
2007-09-12 10:45:29 -07:00
|
|
|
const u32 nVertices = readInt();
|
2007-09-04 11:51:42 -07:00
|
|
|
|
|
|
|
// read vertices
|
2007-12-02 15:57:20 -08:00
|
|
|
mesh.Vertices.set_used(nVertices);
|
2007-09-12 10:45:29 -07:00
|
|
|
for (u32 n=0; n<nVertices; ++n)
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
|
|
|
readVector3(mesh.Vertices[n].Pos);
|
2007-09-12 10:45:29 -07:00
|
|
|
mesh.Vertices[n].Color=0xFFFFFFFF;
|
2007-09-04 11:51:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!checkForTwoFollowingSemicolons())
|
|
|
|
{
|
|
|
|
os::Printer::log("No finishing semicolon in Mesh Vertex Array found in x file", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// read faces
|
2007-09-12 10:45:29 -07:00
|
|
|
const u32 nFaces = readInt();
|
2007-09-04 11:51:42 -07:00
|
|
|
|
|
|
|
mesh.Indices.set_used(nFaces * 3);
|
|
|
|
mesh.IndexCountPerFace.set_used(nFaces);
|
|
|
|
|
2007-09-12 10:45:29 -07:00
|
|
|
core::array<u32> polygonfaces;
|
|
|
|
u32 currentIndex = 0;
|
2007-09-04 11:51:42 -07:00
|
|
|
|
2007-09-12 10:45:29 -07:00
|
|
|
for (u32 k=0; k<nFaces; ++k)
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
2007-09-12 10:45:29 -07:00
|
|
|
const u32 fcnt = readInt();
|
2007-09-04 11:51:42 -07:00
|
|
|
|
|
|
|
if (fcnt != 3)
|
|
|
|
{
|
|
|
|
if (fcnt < 3)
|
|
|
|
{
|
|
|
|
os::Printer::log("Invalid face count (<3) found in Mesh x file reader.", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// read face indices
|
|
|
|
polygonfaces.set_used(fcnt);
|
2007-09-12 10:45:29 -07:00
|
|
|
u32 triangles = (fcnt-2);
|
2007-09-14 15:25:59 -07:00
|
|
|
mesh.Indices.set_used(mesh.Indices.size() + ((triangles-1)*3));
|
2009-01-12 15:14:46 -08:00
|
|
|
mesh.IndexCountPerFace[k] = (u16)(triangles * 3);
|
2007-09-04 11:51:42 -07:00
|
|
|
|
2007-09-12 10:45:29 -07:00
|
|
|
for (u32 f=0; f<fcnt; ++f)
|
2007-09-04 11:51:42 -07:00
|
|
|
polygonfaces[f] = readInt();
|
|
|
|
|
2007-09-12 10:45:29 -07:00
|
|
|
for (u32 jk=0; jk<triangles; ++jk)
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
|
|
|
mesh.Indices[currentIndex++] = polygonfaces[0];
|
|
|
|
mesh.Indices[currentIndex++] = polygonfaces[jk+1];
|
|
|
|
mesh.Indices[currentIndex++] = polygonfaces[jk+2];
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: change face indices in material list
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mesh.Indices[currentIndex++] = readInt();
|
|
|
|
mesh.Indices[currentIndex++] = readInt();
|
|
|
|
mesh.Indices[currentIndex++] = readInt();
|
|
|
|
mesh.IndexCountPerFace[k] = 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-02 15:57:20 -08:00
|
|
|
if (!checkForTwoFollowingSemicolons())
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
|
|
|
os::Printer::log("No finishing semicolon in Mesh Face Array found in x file", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// here, other data objects may follow
|
|
|
|
|
|
|
|
while(true)
|
|
|
|
{
|
|
|
|
core::stringc objectName = getNextToken();
|
|
|
|
|
|
|
|
if (objectName.size() == 0)
|
|
|
|
{
|
|
|
|
os::Printer::log("Unexpected ending found in Mesh in x file.", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (objectName == "}")
|
|
|
|
{
|
|
|
|
break; // mesh finished
|
|
|
|
}
|
2008-12-13 15:09:39 -08:00
|
|
|
|
|
|
|
#ifdef _XREADER_DEBUG
|
|
|
|
os::Printer::log("debug DataObject in mesh:", objectName.c_str() );
|
|
|
|
#endif
|
|
|
|
|
2007-09-04 11:51:42 -07:00
|
|
|
if (objectName == "MeshNormals")
|
|
|
|
{
|
|
|
|
if (!parseDataObjectMeshNormals(mesh))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (objectName == "MeshTextureCoords")
|
|
|
|
{
|
|
|
|
if (!parseDataObjectMeshTextureCoords(mesh))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (objectName == "MeshVertexColors")
|
|
|
|
{
|
|
|
|
if (!parseDataObjectMeshVertexColors(mesh))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (objectName == "MeshMaterialList")
|
|
|
|
{
|
|
|
|
if (!parseDataObjectMeshMaterialList(mesh))
|
2009-02-18 13:25:13 -08:00
|
|
|
return false;
|
2007-09-04 11:51:42 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
if (objectName == "VertexDuplicationIndices")
|
|
|
|
{
|
|
|
|
// we'll ignore vertex duplication indices
|
|
|
|
// TODO: read them
|
|
|
|
if (!parseUnknownDataObject())
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
2008-04-29 05:02:59 -07:00
|
|
|
if (objectName == "DeclData")
|
|
|
|
{
|
|
|
|
// arbitrary vertex attributes
|
|
|
|
// first comes the number of element definitions
|
|
|
|
// then the vertex element type definitions
|
|
|
|
// with format type;tesselator;semantics;usageindex
|
|
|
|
// we want to support 2;0;6;0 == tangent
|
|
|
|
// 2;0;7;0 == binormal
|
2008-10-25 14:22:35 -07:00
|
|
|
// 2;0;3;0 == normal
|
|
|
|
// 1/2;0;5;0 == 1st uv coord
|
2008-04-29 05:02:59 -07:00
|
|
|
// and 1/2;0;5;1 == 2nd uv coord
|
2008-10-25 14:22:35 -07:00
|
|
|
// type==2 is 3xf32, type==1 is 2xf32
|
|
|
|
u32 j;
|
|
|
|
const u32 dcnt = readInt();
|
|
|
|
u16 size = 0;
|
|
|
|
s16 normalpos = -1;
|
|
|
|
s16 uvpos = -1;
|
|
|
|
s16 uv2pos = -1;
|
|
|
|
s16 tangentpos = -1;
|
|
|
|
s16 binormalpos = -1;
|
|
|
|
s16 normaltype = -1;
|
|
|
|
s16 uvtype = -1;
|
|
|
|
s16 uv2type = -1;
|
|
|
|
s16 tangenttype = -1;
|
|
|
|
s16 binormaltype = -1;
|
|
|
|
for (j=0; j<dcnt; ++j)
|
|
|
|
{
|
|
|
|
const u32 type = readInt();
|
2008-10-27 09:42:33 -07:00
|
|
|
//const u32 tesselator = readInt();
|
|
|
|
readInt();
|
2008-10-25 14:22:35 -07:00
|
|
|
const u32 semantics = readInt();
|
|
|
|
const u32 index = readInt();
|
|
|
|
switch (semantics)
|
|
|
|
{
|
|
|
|
case 3:
|
|
|
|
normalpos = size;
|
|
|
|
normaltype = type;
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
if (index==0)
|
|
|
|
{
|
|
|
|
uvpos = size;
|
|
|
|
uvtype = type;
|
|
|
|
}
|
|
|
|
else if (index==1)
|
|
|
|
{
|
|
|
|
uv2pos = size;
|
|
|
|
uv2type = type;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
tangentpos = size;
|
|
|
|
tangenttype = type;
|
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
binormalpos = size;
|
|
|
|
binormaltype = type;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
size += 4;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
size += 8;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
size += 12;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
size += 16;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
case 5:
|
|
|
|
case 6:
|
|
|
|
size += 4;
|
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
size += 8;
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
case 9:
|
|
|
|
size += 4;
|
|
|
|
break;
|
|
|
|
case 10:
|
|
|
|
size += 8;
|
|
|
|
break;
|
|
|
|
case 11:
|
|
|
|
size += 4;
|
|
|
|
break;
|
|
|
|
case 12:
|
|
|
|
size += 8;
|
|
|
|
break;
|
|
|
|
case 13:
|
|
|
|
size += 4;
|
|
|
|
break;
|
|
|
|
case 14:
|
|
|
|
size += 4;
|
|
|
|
break;
|
|
|
|
case 15:
|
|
|
|
size += 4;
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
size += 8;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const u32 datasize = readInt();
|
|
|
|
u32* data = new u32[datasize];
|
|
|
|
for (j=0; j<datasize; ++j)
|
|
|
|
data[j]=readInt();
|
|
|
|
|
|
|
|
if (!checkForOneFollowingSemicolons())
|
|
|
|
{
|
|
|
|
os::Printer::log("No finishing semicolon in DeclData found.", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2008-10-25 14:22:35 -07:00
|
|
|
}
|
|
|
|
if (!checkForClosingBrace())
|
|
|
|
{
|
|
|
|
os::Printer::log("No closing brace in DeclData.", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2008-10-25 14:22:35 -07:00
|
|
|
delete [] data;
|
2008-04-29 05:02:59 -07:00
|
|
|
return false;
|
2008-10-25 14:22:35 -07:00
|
|
|
}
|
|
|
|
u8* dataptr = (u8*) data;
|
2008-12-13 15:09:39 -08:00
|
|
|
if ((uv2pos != -1) && (uv2type == 1))
|
|
|
|
mesh.TCoords2.reallocate(mesh.Vertices.size());
|
2008-10-25 14:22:35 -07:00
|
|
|
for (j=0; j<mesh.Vertices.size(); ++j)
|
|
|
|
{
|
|
|
|
if ((normalpos != -1) && (normaltype == 2))
|
|
|
|
mesh.Vertices[j].Normal.set(*((core::vector3df*)(dataptr+normalpos)));
|
|
|
|
if ((uvpos != -1) && (uvtype == 1))
|
|
|
|
mesh.Vertices[j].TCoords.set(*((core::vector2df*)(dataptr+uvpos)));
|
2008-12-13 15:09:39 -08:00
|
|
|
if ((uv2pos != -1) && (uv2type == 1))
|
|
|
|
mesh.TCoords2.push_back(*((core::vector2df*)(dataptr+uv2pos)));
|
2008-10-25 14:22:35 -07:00
|
|
|
dataptr += size;
|
|
|
|
}
|
|
|
|
delete [] data;
|
2008-04-29 05:02:59 -07:00
|
|
|
}
|
|
|
|
else
|
2008-12-13 15:09:39 -08:00
|
|
|
if (objectName == "FVFData")
|
|
|
|
{
|
2009-01-06 16:36:51 -08:00
|
|
|
if (!readHeadOfDataObject())
|
|
|
|
{
|
|
|
|
os::Printer::log("No starting brace in FVFData found.", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2009-01-06 16:36:51 -08:00
|
|
|
return false;
|
|
|
|
}
|
2008-12-13 15:09:39 -08:00
|
|
|
const u32 dataformat = readInt();
|
|
|
|
const u32 datasize = readInt();
|
|
|
|
u32* data = new u32[datasize];
|
|
|
|
for (u32 j=0; j<datasize; ++j)
|
|
|
|
data[j]=readInt();
|
|
|
|
if (dataformat&0x102) // 2nd uv set
|
|
|
|
{
|
|
|
|
mesh.TCoords2.reallocate(mesh.Vertices.size());
|
|
|
|
u8* dataptr = (u8*) data;
|
|
|
|
const u32 size=((dataformat>>8)&0xf)*sizeof(core::vector2df);
|
|
|
|
for (u32 j=0; j<mesh.Vertices.size(); ++j)
|
|
|
|
{
|
|
|
|
mesh.TCoords2.push_back(*((core::vector2df*)(dataptr)));
|
2008-12-13 15:13:17 -08:00
|
|
|
dataptr += size;
|
2008-12-13 15:09:39 -08:00
|
|
|
}
|
|
|
|
}
|
2009-01-06 16:36:51 -08:00
|
|
|
delete [] data;
|
2008-12-13 15:09:39 -08:00
|
|
|
if (!checkForOneFollowingSemicolons())
|
|
|
|
{
|
|
|
|
os::Printer::log("No finishing semicolon in FVFData found.", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2008-12-13 15:09:39 -08:00
|
|
|
}
|
|
|
|
if (!checkForClosingBrace())
|
|
|
|
{
|
|
|
|
os::Printer::log("No closing brace in FVFData found in x file", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2008-12-13 15:09:39 -08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2007-09-04 11:51:42 -07:00
|
|
|
if (objectName == "XSkinMeshHeader")
|
|
|
|
{
|
2007-09-07 09:09:14 -07:00
|
|
|
if (!parseDataObjectSkinMeshHeader(mesh))
|
2007-09-04 11:51:42 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (objectName == "SkinWeights")
|
|
|
|
{
|
|
|
|
//mesh.SkinWeights.push_back(SXSkinWeight());
|
|
|
|
//if (!parseDataObjectSkinWeights(mesh.SkinWeights.getLast()))
|
|
|
|
if (!parseDataObjectSkinWeights(mesh))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-09-05 01:59:46 -07:00
|
|
|
os::Printer::log("Unknown data object in mesh in x file", objectName.c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
if (!parseUnknownDataObject())
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CXMeshFileLoader::parseDataObjectSkinWeights(SXMesh &mesh)
|
|
|
|
{
|
|
|
|
#ifdef _XREADER_DEBUG
|
|
|
|
os::Printer::log("CXFileReader: Reading mesh skin weights");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!readHeadOfDataObject())
|
|
|
|
{
|
2007-09-07 09:09:14 -07:00
|
|
|
os::Printer::log("No opening brace in Skin Weights found in .x file", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
core::stringc TransformNodeName;
|
|
|
|
|
|
|
|
if (!getNextTokenAsString(TransformNodeName))
|
|
|
|
{
|
2007-09-07 09:09:14 -07:00
|
|
|
os::Printer::log("Unknown syntax while reading transfrom node name string in .x file", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-09-17 04:09:07 -07:00
|
|
|
mesh.HasSkinning=true;
|
|
|
|
|
2007-09-04 11:51:42 -07:00
|
|
|
CSkinnedMesh::SJoint *joint=0;
|
|
|
|
|
2008-01-13 16:23:02 -08:00
|
|
|
u32 n;
|
|
|
|
for (n=0; n < AnimatedMesh->getAllJoints().size(); ++n)
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
|
|
|
if (AnimatedMesh->getAllJoints()[n]->Name==TransformNodeName)
|
2007-09-06 09:14:33 -07:00
|
|
|
{
|
2007-09-04 11:51:42 -07:00
|
|
|
joint=AnimatedMesh->getAllJoints()[n];
|
2007-09-06 09:14:33 -07:00
|
|
|
break;
|
|
|
|
}
|
2007-09-04 11:51:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!joint)
|
|
|
|
{
|
2007-09-05 01:59:46 -07:00
|
|
|
#ifdef _XREADER_DEBUG
|
2007-09-10 09:15:36 -07:00
|
|
|
os::Printer::log("creating joint for skinning ", TransformNodeName.c_str());
|
2007-09-05 01:59:46 -07:00
|
|
|
#endif
|
2008-01-13 16:23:02 -08:00
|
|
|
n = AnimatedMesh->getAllJoints().size();
|
2007-09-04 11:51:42 -07:00
|
|
|
joint=AnimatedMesh->createJoint(0);
|
|
|
|
joint->Name=TransformNodeName;
|
|
|
|
}
|
|
|
|
|
|
|
|
// read vertex weights
|
2007-09-12 10:45:29 -07:00
|
|
|
const u32 nWeights = readInt();
|
2007-09-04 11:51:42 -07:00
|
|
|
|
|
|
|
// read vertex indices
|
2007-09-12 10:45:29 -07:00
|
|
|
u32 i;
|
2007-09-04 11:51:42 -07:00
|
|
|
|
2007-09-07 09:09:14 -07:00
|
|
|
const u32 jointStart = joint->Weights.size();
|
|
|
|
joint->Weights.reallocate(jointStart+nWeights);
|
|
|
|
|
2008-01-13 16:23:02 -08:00
|
|
|
mesh.WeightJoint.reallocate( mesh.WeightJoint.size() + nWeights );
|
|
|
|
mesh.WeightNum.reallocate( mesh.WeightNum.size() + nWeights );
|
2007-09-17 19:51:06 -07:00
|
|
|
|
2007-09-04 11:51:42 -07:00
|
|
|
for (i=0; i<nWeights; ++i)
|
2007-09-07 09:09:14 -07:00
|
|
|
{
|
2008-01-13 16:23:02 -08:00
|
|
|
mesh.WeightJoint.push_back(n);
|
|
|
|
mesh.WeightNum.push_back(joint->Weights.size());
|
|
|
|
|
2007-09-07 09:09:14 -07:00
|
|
|
CSkinnedMesh::SWeight *weight=AnimatedMesh->createWeight(joint);
|
|
|
|
|
|
|
|
weight->buffer_id=0;
|
|
|
|
weight->vertex_id=readInt();
|
|
|
|
}
|
2007-09-04 11:51:42 -07:00
|
|
|
|
|
|
|
// read vertex weights
|
|
|
|
|
2008-02-14 01:33:45 -08:00
|
|
|
for (i=jointStart; i<jointStart+nWeights; ++i)
|
2007-09-07 09:09:14 -07:00
|
|
|
joint->Weights[i].strength = readFloat();
|
2007-09-04 11:51:42 -07:00
|
|
|
|
|
|
|
// read matrix offset
|
|
|
|
|
2007-09-07 09:09:14 -07:00
|
|
|
// transforms the mesh vertices to the space of the bone
|
|
|
|
// When concatenated to the bone's transform, this provides the
|
|
|
|
// world space coordinates of the mesh as affected by the bone
|
|
|
|
core::matrix4& MatrixOffset = joint->GlobalInversedMatrix;
|
2007-09-04 11:51:42 -07:00
|
|
|
|
2008-02-12 07:32:39 -08:00
|
|
|
readMatrix(MatrixOffset);
|
2007-09-04 11:51:42 -07:00
|
|
|
|
2008-02-12 07:32:39 -08:00
|
|
|
if (!checkForOneFollowingSemicolons())
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
|
|
|
os::Printer::log("No finishing semicolon in Skin Weights found in x file", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
}
|
|
|
|
|
2007-09-10 09:15:36 -07:00
|
|
|
if (!checkForClosingBrace())
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
|
|
|
os::Printer::log("No closing brace in Skin Weights found in x file", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-07 09:09:14 -07:00
|
|
|
bool CXMeshFileLoader::parseDataObjectSkinMeshHeader(SXMesh& mesh)
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
|
|
|
#ifdef _XREADER_DEBUG
|
|
|
|
os::Printer::log("CXFileReader: Reading skin mesh header");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!readHeadOfDataObject())
|
|
|
|
{
|
2007-09-07 09:09:14 -07:00
|
|
|
os::Printer::log("No opening brace in Skin Mesh header found in .x file", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-09-07 09:09:14 -07:00
|
|
|
mesh.MaxSkinWeightsPerVertex = readInt();
|
|
|
|
mesh.MaxSkinWeightsPerFace = readInt();
|
|
|
|
mesh.BoneCount = readInt();
|
|
|
|
|
2007-09-06 16:20:02 -07:00
|
|
|
if (!BinaryFormat)
|
2007-09-04 11:51:42 -07:00
|
|
|
getNextToken(); // skip semicolon
|
2007-09-07 09:09:14 -07:00
|
|
|
|
2007-09-10 09:15:36 -07:00
|
|
|
if (!checkForClosingBrace())
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
2007-09-10 09:15:36 -07:00
|
|
|
os::Printer::log("No closing brace in skin mesh header in x file", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CXMeshFileLoader::parseDataObjectMeshNormals(SXMesh &mesh)
|
|
|
|
{
|
|
|
|
#ifdef _XREADER_DEBUG
|
|
|
|
os::Printer::log("CXFileReader: reading mesh normals");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!readHeadOfDataObject())
|
|
|
|
{
|
|
|
|
os::Printer::log("No opening brace in Mesh Normals found in x file", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// read count
|
2007-09-12 10:45:29 -07:00
|
|
|
const u32 nNormals = readInt();
|
2007-09-06 09:14:33 -07:00
|
|
|
core::array<core::vector3df> normals;
|
|
|
|
normals.set_used(nNormals);
|
2007-09-04 11:51:42 -07:00
|
|
|
|
|
|
|
// read normals
|
2007-09-12 10:45:29 -07:00
|
|
|
for (u32 i=0; i<nNormals; ++i)
|
2007-09-06 09:14:33 -07:00
|
|
|
readVector3(normals[i]);
|
2007-09-04 11:51:42 -07:00
|
|
|
|
|
|
|
if (!checkForTwoFollowingSemicolons())
|
|
|
|
{
|
|
|
|
os::Printer::log("No finishing semicolon in Mesh Normals Array found in x file", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
}
|
|
|
|
|
2007-09-12 10:45:29 -07:00
|
|
|
core::array<u32> normalIndices;
|
|
|
|
normalIndices.set_used(mesh.Indices.size());
|
2007-09-04 11:51:42 -07:00
|
|
|
|
|
|
|
// read face normal indices
|
2007-09-12 10:45:29 -07:00
|
|
|
const u32 nFNormals = readInt();
|
2007-09-04 11:51:42 -07:00
|
|
|
|
2007-09-12 10:45:29 -07:00
|
|
|
u32 normalidx = 0;
|
|
|
|
core::array<u32> polygonfaces;
|
|
|
|
for (u32 k=0; k<nFNormals; ++k)
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
2007-09-12 10:45:29 -07:00
|
|
|
const u32 fcnt = readInt();
|
|
|
|
u32 triangles = fcnt - 2;
|
|
|
|
u32 indexcount = triangles * 3;
|
2007-09-04 11:51:42 -07:00
|
|
|
|
|
|
|
if (indexcount != mesh.IndexCountPerFace[k])
|
|
|
|
{
|
|
|
|
os::Printer::log("Not matching normal and face index count found in x file", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (indexcount == 3)
|
|
|
|
{
|
|
|
|
// default, only one triangle in this face
|
2007-09-12 10:45:29 -07:00
|
|
|
for (u32 h=0; h<3; ++h)
|
2007-09-06 09:14:33 -07:00
|
|
|
{
|
2007-09-12 10:45:29 -07:00
|
|
|
const u32 normalnum = readInt();
|
2007-09-06 09:14:33 -07:00
|
|
|
mesh.Vertices[mesh.Indices[normalidx++]].Normal.set(normals[normalnum]);
|
|
|
|
}
|
2007-09-04 11:51:42 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
polygonfaces.set_used(fcnt);
|
2007-09-12 10:45:29 -07:00
|
|
|
// multiple triangles in this face
|
|
|
|
for (u32 h=0; h<fcnt; ++h)
|
2007-09-04 11:51:42 -07:00
|
|
|
polygonfaces[h] = readInt();
|
|
|
|
|
2007-09-12 10:45:29 -07:00
|
|
|
for (u32 jk=0; jk<triangles; ++jk)
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
2007-09-06 09:14:33 -07:00
|
|
|
mesh.Vertices[mesh.Indices[normalidx++]].Normal.set(normals[polygonfaces[0]]);
|
|
|
|
mesh.Vertices[mesh.Indices[normalidx++]].Normal.set(normals[polygonfaces[jk+1]]);
|
|
|
|
mesh.Vertices[mesh.Indices[normalidx++]].Normal.set(normals[polygonfaces[jk+2]]);
|
2007-09-04 11:51:42 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!checkForTwoFollowingSemicolons())
|
|
|
|
{
|
|
|
|
os::Printer::log("No finishing semicolon in Mesh Face Normals Array found in x file", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
}
|
2007-09-10 09:15:36 -07:00
|
|
|
|
|
|
|
if (!checkForClosingBrace())
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
|
|
|
os::Printer::log("No closing brace in Mesh Normals found in x file", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CXMeshFileLoader::parseDataObjectMeshTextureCoords(SXMesh &mesh)
|
|
|
|
{
|
|
|
|
#ifdef _XREADER_DEBUG
|
|
|
|
os::Printer::log("CXFileReader: reading mesh texture coordinates");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!readHeadOfDataObject())
|
|
|
|
{
|
|
|
|
os::Printer::log("No opening brace in Mesh Texture Coordinates found in x file", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-09-12 10:45:29 -07:00
|
|
|
const u32 nCoords = readInt();
|
|
|
|
for (u32 i=0; i<nCoords; ++i)
|
2007-09-04 11:51:42 -07:00
|
|
|
readVector2(mesh.Vertices[i].TCoords);
|
|
|
|
|
|
|
|
if (!checkForTwoFollowingSemicolons())
|
|
|
|
{
|
|
|
|
os::Printer::log("No finishing semicolon in Mesh Texture Coordinates Array found in x file", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
}
|
|
|
|
|
2007-09-10 09:15:36 -07:00
|
|
|
if (!checkForClosingBrace())
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
|
|
|
os::Printer::log("No closing brace in Mesh Texture Coordinates Array found in x file", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CXMeshFileLoader::parseDataObjectMeshVertexColors(SXMesh &mesh)
|
|
|
|
{
|
|
|
|
#ifdef _XREADER_DEBUG
|
|
|
|
os::Printer::log("CXFileReader: reading mesh vertex colors");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!readHeadOfDataObject())
|
|
|
|
{
|
|
|
|
os::Printer::log("No opening brace for Mesh Vertex Colors found in x file", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-09-18 05:00:03 -07:00
|
|
|
mesh.HasVertexColors=true;
|
2007-09-10 06:11:47 -07:00
|
|
|
const u32 nColors = readInt();
|
|
|
|
for (u32 i=0; i<nColors; ++i)
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
2007-09-10 06:11:47 -07:00
|
|
|
const u32 Index=readInt();
|
2007-09-18 05:00:03 -07:00
|
|
|
if (Index>=mesh.Vertices.size())
|
|
|
|
{
|
|
|
|
os::Printer::log("index value in parseDataObjectMeshVertexColors out of bounds", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-18 05:00:03 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
readRGBA(mesh.Vertices[Index].Color);
|
2007-09-10 06:11:47 -07:00
|
|
|
checkForOneFollowingSemicolons();
|
2007-09-04 11:51:42 -07:00
|
|
|
}
|
|
|
|
|
2007-09-10 06:11:47 -07:00
|
|
|
if (!checkForOneFollowingSemicolons())
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
|
|
|
os::Printer::log("No finishing semicolon in Mesh Vertex Colors Array found in x file", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
}
|
|
|
|
|
2007-09-10 09:15:36 -07:00
|
|
|
if (!checkForClosingBrace())
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
|
|
|
os::Printer::log("No closing brace in Mesh Texture Coordinates Array found in x file", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CXMeshFileLoader::parseDataObjectMeshMaterialList(SXMesh &mesh)
|
|
|
|
{
|
|
|
|
#ifdef _XREADER_DEBUG
|
|
|
|
os::Printer::log("CXFileReader: Reading mesh material list");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!readHeadOfDataObject())
|
|
|
|
{
|
|
|
|
os::Printer::log("No opening brace in Mesh Material List found in x file", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// read material count
|
2007-09-07 07:18:47 -07:00
|
|
|
mesh.Materials.reallocate(readInt());
|
2007-09-04 11:51:42 -07:00
|
|
|
|
|
|
|
// read non triangulated face material index count
|
2007-09-12 10:45:29 -07:00
|
|
|
const u32 nFaceIndices = readInt();
|
2007-09-04 11:51:42 -07:00
|
|
|
|
2008-10-01 04:36:20 -07:00
|
|
|
// There seems to be a compact representation of "all faces the same material"
|
|
|
|
// being represented as 1;1;0;; which means 1 material, 1 face with first material
|
|
|
|
// all the other faces have to obey then, so check is disabled
|
|
|
|
//if (nFaceIndices != mesh.IndexCountPerFace.size())
|
|
|
|
// os::Printer::log("Index count per face not equal to face material index count in x file.", ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
|
2007-09-07 07:18:47 -07:00
|
|
|
// read non triangulated face indices and create triangulated ones
|
|
|
|
mesh.FaceMaterialIndices.set_used( mesh.Indices.size() / 3);
|
2007-09-12 10:45:29 -07:00
|
|
|
u32 triangulatedindex = 0;
|
2008-10-01 04:36:20 -07:00
|
|
|
u32 ind = 0;
|
|
|
|
for (u32 tfi=0; tfi<mesh.IndexCountPerFace.size(); ++tfi)
|
2007-09-07 07:18:47 -07:00
|
|
|
{
|
2008-10-01 04:36:20 -07:00
|
|
|
if (tfi<nFaceIndices)
|
|
|
|
ind = readInt();
|
2007-09-12 10:45:29 -07:00
|
|
|
const u32 fc = mesh.IndexCountPerFace[tfi]/3;
|
|
|
|
for (u32 k=0; k<fc; ++k)
|
|
|
|
mesh.FaceMaterialIndices[triangulatedindex++] = ind;
|
2007-09-07 07:18:47 -07:00
|
|
|
}
|
2007-09-04 11:51:42 -07:00
|
|
|
|
|
|
|
// in version 03.02, the face indices end with two semicolons.
|
|
|
|
// commented out version check, as version 03.03 exported from blender also has 2 semicolons
|
2007-09-06 16:20:02 -07:00
|
|
|
if (!BinaryFormat) // && MajorVersion == 3 && MinorVersion <= 2)
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
|
|
|
if (P[0] == ';')
|
|
|
|
++P;
|
|
|
|
}
|
|
|
|
|
|
|
|
// read following data objects
|
|
|
|
|
|
|
|
while(true)
|
|
|
|
{
|
|
|
|
core::stringc objectName = getNextToken();
|
|
|
|
|
|
|
|
if (objectName.size() == 0)
|
|
|
|
{
|
2007-09-07 07:18:47 -07:00
|
|
|
os::Printer::log("Unexpected ending found in Mesh Material list in .x file.", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (objectName == "}")
|
|
|
|
{
|
|
|
|
break; // material list finished
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (objectName == "{")
|
|
|
|
{
|
|
|
|
// template materials now available thanks to joeWright
|
|
|
|
objectName = getNextToken();
|
|
|
|
for (u32 i=0; i<TemplateMaterials.size(); ++i)
|
|
|
|
if (TemplateMaterials[i].Name == objectName)
|
|
|
|
mesh.Materials.push_back(TemplateMaterials[i].Material);
|
|
|
|
getNextToken(); // skip }
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (objectName == "Material")
|
|
|
|
{
|
|
|
|
mesh.Materials.push_back(video::SMaterial());
|
|
|
|
if (!parseDataObjectMaterial(mesh.Materials.getLast()))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (objectName == ";")
|
|
|
|
{
|
|
|
|
// ignore
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-09-05 01:59:46 -07:00
|
|
|
os::Printer::log("Unknown data object in material list in x file", objectName.c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
if (!parseUnknownDataObject())
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CXMeshFileLoader::parseDataObjectMaterial(video::SMaterial& material)
|
|
|
|
{
|
|
|
|
#ifdef _XREADER_DEBUG
|
|
|
|
os::Printer::log("CXFileReader: Reading mesh material");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!readHeadOfDataObject())
|
|
|
|
{
|
2007-09-07 09:09:14 -07:00
|
|
|
os::Printer::log("No opening brace in Mesh Material found in .x file", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// read RGBA
|
|
|
|
readRGBA(material.DiffuseColor); checkForOneFollowingSemicolons();
|
|
|
|
|
|
|
|
// read power
|
2007-09-07 09:09:14 -07:00
|
|
|
material.Shininess = readFloat();
|
2007-09-04 11:51:42 -07:00
|
|
|
|
|
|
|
// read specular
|
|
|
|
readRGB(material.SpecularColor); checkForOneFollowingSemicolons();
|
|
|
|
|
|
|
|
// read emissive
|
|
|
|
readRGB(material.EmissiveColor); checkForOneFollowingSemicolons();
|
|
|
|
|
|
|
|
// read other data objects
|
2008-12-13 15:09:39 -08:00
|
|
|
int textureLayer=0;
|
2007-09-04 11:51:42 -07:00
|
|
|
while(true)
|
|
|
|
{
|
|
|
|
core::stringc objectName = getNextToken();
|
|
|
|
|
|
|
|
if (objectName.size() == 0)
|
|
|
|
{
|
2007-09-07 09:09:14 -07:00
|
|
|
os::Printer::log("Unexpected ending found in Mesh Material in .x file.", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (objectName == "}")
|
|
|
|
{
|
|
|
|
break; // material finished
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (objectName.equals_ignore_case("TextureFilename"))
|
|
|
|
{
|
|
|
|
// some exporters write "TextureFileName" instead.
|
|
|
|
core::stringc TextureFileName;
|
|
|
|
if (!parseDataObjectTextureFilename(TextureFileName))
|
|
|
|
return false;
|
|
|
|
|
2007-09-06 16:20:02 -07:00
|
|
|
// original name
|
2009-01-12 15:14:46 -08:00
|
|
|
if (FileSystem->existFile(TextureFileName))
|
|
|
|
material.setTexture(textureLayer, SceneManager->getVideoDriver()->getTexture(TextureFileName));
|
2008-10-25 14:22:35 -07:00
|
|
|
// mesh path
|
|
|
|
else
|
|
|
|
{
|
2009-01-12 15:14:46 -08:00
|
|
|
TextureFileName=FilePath + FileSystem->getFileBasename(TextureFileName);
|
|
|
|
if (FileSystem->existFile(TextureFileName))
|
|
|
|
material.setTexture(textureLayer, SceneManager->getVideoDriver()->getTexture(TextureFileName));
|
2008-10-25 14:22:35 -07:00
|
|
|
// working directory
|
|
|
|
else
|
2009-01-12 15:14:46 -08:00
|
|
|
material.setTexture(textureLayer, SceneManager->getVideoDriver()->getTexture(FileSystem->getFileBasename(TextureFileName)));
|
2008-10-25 14:22:35 -07:00
|
|
|
}
|
2008-12-13 15:09:39 -08:00
|
|
|
++textureLayer;
|
|
|
|
if (textureLayer==2)
|
|
|
|
material.MaterialType=video::EMT_LIGHTMAP;
|
2008-10-25 14:22:35 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
if (objectName.equals_ignore_case("NormalmapFilename"))
|
|
|
|
{
|
|
|
|
// some exporters write "NormalmapFileName" instead.
|
|
|
|
core::stringc TextureFileName;
|
|
|
|
if (!parseDataObjectTextureFilename(TextureFileName))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// original name
|
2009-01-12 15:14:46 -08:00
|
|
|
if (FileSystem->existFile(TextureFileName))
|
|
|
|
material.setTexture(1, SceneManager->getVideoDriver()->getTexture(TextureFileName));
|
2007-09-06 16:20:02 -07:00
|
|
|
// mesh path
|
2008-01-29 16:17:16 -08:00
|
|
|
else
|
2007-09-06 16:20:02 -07:00
|
|
|
{
|
2009-01-12 15:14:46 -08:00
|
|
|
TextureFileName=FilePath + FileSystem->getFileBasename(TextureFileName);
|
|
|
|
if (FileSystem->existFile(TextureFileName))
|
|
|
|
material.setTexture(1, SceneManager->getVideoDriver()->getTexture(TextureFileName));
|
2008-01-29 16:17:16 -08:00
|
|
|
// working directory
|
|
|
|
else
|
2009-01-12 15:14:46 -08:00
|
|
|
material.setTexture(1, SceneManager->getVideoDriver()->getTexture(FileSystem->getFileBasename(TextureFileName)));
|
2007-09-06 16:20:02 -07:00
|
|
|
}
|
2008-12-13 15:09:39 -08:00
|
|
|
if (textureLayer==1)
|
|
|
|
++textureLayer;
|
2007-09-04 11:51:42 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-09-07 09:09:14 -07:00
|
|
|
os::Printer::log("Unknown data object in material in .x file", objectName.c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
if (!parseUnknownDataObject())
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CXMeshFileLoader::parseDataObjectAnimationSet()
|
|
|
|
{
|
2007-09-10 09:15:36 -07:00
|
|
|
#ifdef _XREADER_DEBUG
|
2007-09-04 11:51:42 -07:00
|
|
|
os::Printer::log("CXFileReader: Reading animation set");
|
2007-09-10 09:15:36 -07:00
|
|
|
#endif
|
2007-09-04 11:51:42 -07:00
|
|
|
|
|
|
|
core::stringc AnimationName;
|
|
|
|
|
|
|
|
if (!readHeadOfDataObject(&AnimationName))
|
|
|
|
{
|
|
|
|
os::Printer::log("No opening brace in Animation Set found in x file", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
while(true)
|
|
|
|
{
|
|
|
|
core::stringc objectName = getNextToken();
|
|
|
|
|
|
|
|
if (objectName.size() == 0)
|
|
|
|
{
|
|
|
|
os::Printer::log("Unexpected ending found in Animation set in x file.", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (objectName == "}")
|
|
|
|
{
|
|
|
|
break; // animation set finished
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (objectName == "Animation")
|
|
|
|
{
|
|
|
|
if (!parseDataObjectAnimation())
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-09-05 01:59:46 -07:00
|
|
|
os::Printer::log("Unknown data object in animation set in x file", objectName.c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
if (!parseUnknownDataObject())
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CXMeshFileLoader::parseDataObjectAnimation()
|
|
|
|
{
|
|
|
|
#ifdef _XREADER_DEBUG
|
|
|
|
os::Printer::log("CXFileReader: reading animation");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!readHeadOfDataObject())
|
|
|
|
{
|
|
|
|
os::Printer::log("No opening brace in Animation found in x file", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//anim.closed = true;
|
|
|
|
//anim.linearPositionQuality = true;
|
|
|
|
CSkinnedMesh::SJoint animationDump;
|
|
|
|
|
2007-09-10 06:11:47 -07:00
|
|
|
core::stringc FrameName;
|
2007-09-04 11:51:42 -07:00
|
|
|
|
|
|
|
while(true)
|
|
|
|
{
|
|
|
|
core::stringc objectName = getNextToken();
|
|
|
|
|
|
|
|
if (objectName.size() == 0)
|
|
|
|
{
|
|
|
|
os::Printer::log("Unexpected ending found in Animation in x file.", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (objectName == "}")
|
|
|
|
{
|
|
|
|
break; // animation finished
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (objectName == "AnimationKey")
|
|
|
|
{
|
2007-09-10 09:15:36 -07:00
|
|
|
if (!parseDataObjectAnimationKey(&animationDump))
|
|
|
|
return false;
|
2007-09-04 11:51:42 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
if (objectName == "AnimationOptions")
|
|
|
|
{
|
|
|
|
//TODO: parse options.
|
|
|
|
if (!parseUnknownDataObject())
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (objectName == "{")
|
|
|
|
{
|
|
|
|
// read frame name
|
|
|
|
FrameName = getNextToken();
|
|
|
|
|
2007-09-10 09:15:36 -07:00
|
|
|
if (!checkForClosingBrace())
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
|
|
|
os::Printer::log("Unexpected ending found in Animation in x file.", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-09-09 16:09:06 -07:00
|
|
|
os::Printer::log("Unknown data object in animation in x file", objectName.c_str(), ELL_WARNING);
|
|
|
|
if (!parseUnknownDataObject())
|
|
|
|
return false;
|
2007-09-04 11:51:42 -07:00
|
|
|
}
|
2007-09-10 09:15:36 -07:00
|
|
|
}
|
2007-09-04 11:51:42 -07:00
|
|
|
|
2007-09-10 09:15:36 -07:00
|
|
|
if (FrameName.size() != 0)
|
|
|
|
{
|
|
|
|
#ifdef _XREADER_DEBUG
|
|
|
|
os::Printer::log("getting name: ", FrameName.c_str());
|
2007-09-05 01:59:46 -07:00
|
|
|
#endif
|
2007-09-10 09:15:36 -07:00
|
|
|
CSkinnedMesh::SJoint *joint=0;
|
2007-09-06 22:55:34 -07:00
|
|
|
|
2007-09-10 09:15:36 -07:00
|
|
|
u32 n;
|
2008-10-25 14:22:35 -07:00
|
|
|
for (n=0; n < AnimatedMesh->getAllJoints().size(); ++n)
|
2007-09-10 09:15:36 -07:00
|
|
|
{
|
|
|
|
if (AnimatedMesh->getAllJoints()[n]->Name==FrameName)
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
2007-09-10 09:15:36 -07:00
|
|
|
joint=AnimatedMesh->getAllJoints()[n];
|
|
|
|
break;
|
2007-09-04 11:51:42 -07:00
|
|
|
}
|
2007-09-10 09:15:36 -07:00
|
|
|
}
|
2007-09-09 16:09:06 -07:00
|
|
|
|
2007-09-10 09:15:36 -07:00
|
|
|
if (!joint)
|
|
|
|
{
|
|
|
|
#ifdef _XREADER_DEBUG
|
|
|
|
os::Printer::log("creating joint for animation ", FrameName.c_str());
|
|
|
|
#endif
|
|
|
|
joint=AnimatedMesh->createJoint(0);
|
|
|
|
joint->Name=FrameName;
|
|
|
|
}
|
2007-09-04 11:51:42 -07:00
|
|
|
|
2007-09-10 09:15:36 -07:00
|
|
|
joint->PositionKeys.reallocate(joint->PositionKeys.size()+animationDump.PositionKeys.size());
|
2008-10-25 14:22:35 -07:00
|
|
|
for (n=0; n<animationDump.PositionKeys.size(); ++n)
|
2007-09-10 09:15:36 -07:00
|
|
|
{
|
2008-02-12 07:32:39 -08:00
|
|
|
joint->PositionKeys.push_back(animationDump.PositionKeys[n]);
|
2007-09-10 09:15:36 -07:00
|
|
|
}
|
2007-09-04 11:51:42 -07:00
|
|
|
|
2007-09-10 09:15:36 -07:00
|
|
|
joint->ScaleKeys.reallocate(joint->ScaleKeys.size()+animationDump.ScaleKeys.size());
|
2008-10-25 14:22:35 -07:00
|
|
|
for (n=0; n<animationDump.ScaleKeys.size(); ++n)
|
2007-09-10 09:15:36 -07:00
|
|
|
{
|
2008-02-12 07:32:39 -08:00
|
|
|
joint->ScaleKeys.push_back(animationDump.ScaleKeys[n]);
|
2007-09-10 09:15:36 -07:00
|
|
|
}
|
2007-09-04 11:51:42 -07:00
|
|
|
|
2007-09-10 09:15:36 -07:00
|
|
|
joint->RotationKeys.reallocate(joint->RotationKeys.size()+animationDump.RotationKeys.size());
|
2008-10-25 14:22:35 -07:00
|
|
|
for (n=0; n<animationDump.RotationKeys.size(); ++n)
|
2007-09-10 09:15:36 -07:00
|
|
|
{
|
2008-02-12 07:32:39 -08:00
|
|
|
joint->RotationKeys.push_back(animationDump.RotationKeys[n]);
|
2007-09-04 11:51:42 -07:00
|
|
|
}
|
|
|
|
}
|
2007-09-10 09:15:36 -07:00
|
|
|
else
|
2007-09-05 01:59:46 -07:00
|
|
|
os::Printer::log("joint name was never given", ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CXMeshFileLoader::parseDataObjectAnimationKey(ISkinnedMesh::SJoint *joint)
|
|
|
|
{
|
|
|
|
#ifdef _XREADER_DEBUG
|
|
|
|
os::Printer::log("CXFileReader: reading animation key");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!readHeadOfDataObject())
|
|
|
|
{
|
|
|
|
os::Printer::log("No opening brace in Animation Key found in x file", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// read key type
|
|
|
|
|
2007-09-12 10:45:29 -07:00
|
|
|
const u32 keyType = readInt();
|
2007-09-04 11:51:42 -07:00
|
|
|
|
2007-09-12 10:45:29 -07:00
|
|
|
if (keyType > 4)
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
|
|
|
os::Printer::log("Unknown key type found in Animation Key in x file", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// read number of keys
|
2007-09-12 10:45:29 -07:00
|
|
|
const u32 numberOfKeys = readInt();
|
2007-09-04 11:51:42 -07:00
|
|
|
|
|
|
|
// eat the semicolon after the "0". if there are keys present, readInt()
|
|
|
|
// does this for us. If there aren't, we need to do it explicitly
|
2007-09-10 09:15:36 -07:00
|
|
|
if (numberOfKeys == 0)
|
|
|
|
checkForOneFollowingSemicolons();
|
2007-09-04 11:51:42 -07:00
|
|
|
|
2007-09-12 10:45:29 -07:00
|
|
|
for (u32 i=0; i<numberOfKeys; ++i)
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
2007-09-10 09:15:36 -07:00
|
|
|
// read time
|
2008-02-12 07:32:39 -08:00
|
|
|
const f32 time = (f32)readInt();
|
2007-09-04 11:51:42 -07:00
|
|
|
|
|
|
|
// read keys
|
|
|
|
switch(keyType)
|
|
|
|
{
|
|
|
|
case 0: //rotation
|
|
|
|
{
|
|
|
|
//read quaternions
|
|
|
|
|
|
|
|
// read count
|
|
|
|
if (readInt() != 4)
|
|
|
|
{
|
|
|
|
os::Printer::log("Expected 4 numbers in animation key in x file", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
f32 W = -readFloat();
|
|
|
|
f32 X = -readFloat();
|
|
|
|
f32 Y = -readFloat();
|
|
|
|
f32 Z = -readFloat();
|
|
|
|
|
|
|
|
if (!checkForTwoFollowingSemicolons())
|
|
|
|
{
|
|
|
|
os::Printer::log("No finishing semicolon after quaternion animation key in x file", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
ISkinnedMesh::SRotationKey *key=AnimatedMesh->createRotationKey(joint);
|
2008-02-12 07:32:39 -08:00
|
|
|
key->frame=time;
|
2007-09-04 11:51:42 -07:00
|
|
|
key->rotation.set(X,Y,Z,W);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1: //scale
|
|
|
|
case 2: //position
|
|
|
|
{
|
|
|
|
// read vectors
|
|
|
|
|
2007-09-10 09:15:36 -07:00
|
|
|
// read count
|
|
|
|
if (readInt() != 3)
|
|
|
|
{
|
|
|
|
os::Printer::log("Expected 3 numbers in animation key in x file", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-10 09:15:36 -07:00
|
|
|
return false;
|
|
|
|
}
|
2007-09-04 11:51:42 -07:00
|
|
|
|
2007-09-10 09:15:36 -07:00
|
|
|
core::vector3df vector;
|
|
|
|
readVector3(vector);
|
2007-09-04 11:51:42 -07:00
|
|
|
|
2007-09-10 09:15:36 -07:00
|
|
|
if (!checkForTwoFollowingSemicolons())
|
|
|
|
{
|
|
|
|
os::Printer::log("No finishing semicolon after vector animation key in x file", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-10 09:15:36 -07:00
|
|
|
}
|
2007-09-04 11:51:42 -07:00
|
|
|
|
2007-09-10 09:15:36 -07:00
|
|
|
if (keyType==2)
|
|
|
|
{
|
|
|
|
ISkinnedMesh::SPositionKey *key=AnimatedMesh->createPositionKey(joint);
|
2008-02-12 07:32:39 -08:00
|
|
|
key->frame=time;
|
2007-09-10 09:15:36 -07:00
|
|
|
key->position=vector;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ISkinnedMesh::SScaleKey *key=AnimatedMesh->createScaleKey(joint);
|
2008-02-12 07:32:39 -08:00
|
|
|
key->frame=time;
|
2007-09-10 09:15:36 -07:00
|
|
|
key->scale=vector;
|
|
|
|
}
|
2007-09-04 11:51:42 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
case 4:
|
|
|
|
{
|
|
|
|
// read matrix
|
|
|
|
|
|
|
|
// read count
|
|
|
|
if (readInt() != 16)
|
|
|
|
{
|
|
|
|
os::Printer::log("Expected 16 numbers in animation key in x file", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// read matrix
|
2008-02-12 07:32:39 -08:00
|
|
|
core::matrix4 mat(core::matrix4::EM4CONST_NOTHING);
|
|
|
|
readMatrix(mat);
|
2007-09-04 11:51:42 -07:00
|
|
|
|
2008-02-12 07:32:39 -08:00
|
|
|
//mat=joint->LocalMatrix*mat;
|
2007-09-04 11:51:42 -07:00
|
|
|
|
2008-02-12 07:32:39 -08:00
|
|
|
if (!checkForOneFollowingSemicolons())
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
|
|
|
os::Printer::log("No finishing semicolon after matrix animation key in x file", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
}
|
|
|
|
|
2008-02-12 07:32:39 -08:00
|
|
|
//core::vector3df rotation = mat.getRotationDegrees();
|
2007-09-04 11:51:42 -07:00
|
|
|
|
|
|
|
ISkinnedMesh::SRotationKey *keyR=AnimatedMesh->createRotationKey(joint);
|
2008-02-12 07:32:39 -08:00
|
|
|
keyR->frame=time;
|
|
|
|
keyR->rotation= core::quaternion(mat);
|
2007-09-04 11:51:42 -07:00
|
|
|
|
|
|
|
|
|
|
|
ISkinnedMesh::SPositionKey *keyP=AnimatedMesh->createPositionKey(joint);
|
2008-02-12 07:32:39 -08:00
|
|
|
keyP->frame=time;
|
|
|
|
keyP->position=mat.getTranslation();
|
2007-09-04 11:51:42 -07:00
|
|
|
|
2008-02-21 05:03:22 -08:00
|
|
|
/*
|
2008-02-12 07:32:39 -08:00
|
|
|
core::vector3df scale=mat.getScale();
|
2007-09-04 11:51:42 -07:00
|
|
|
|
2008-02-21 05:03:22 -08:00
|
|
|
if (scale.X==0)
|
|
|
|
scale.X=1;
|
|
|
|
if (scale.Y==0)
|
|
|
|
scale.Y=1;
|
|
|
|
if (scale.Z==0)
|
|
|
|
scale.Z=1;
|
2007-09-04 11:51:42 -07:00
|
|
|
ISkinnedMesh::SScaleKey *keyS=AnimatedMesh->createScaleKey(joint);
|
2008-02-12 07:32:39 -08:00
|
|
|
keyS->frame=time;
|
2007-09-04 11:51:42 -07:00
|
|
|
keyS->scale=scale;
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
} // end switch
|
|
|
|
}
|
|
|
|
|
2008-10-01 04:36:20 -07:00
|
|
|
if (!checkForOneFollowingSemicolons())
|
|
|
|
--P;
|
2007-09-04 11:51:42 -07:00
|
|
|
|
2007-09-10 09:15:36 -07:00
|
|
|
if (!checkForClosingBrace())
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
2007-09-10 09:15:36 -07:00
|
|
|
os::Printer::log("No closing brace in animation key in x file", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CXMeshFileLoader::parseDataObjectTextureFilename(core::stringc& texturename)
|
|
|
|
{
|
|
|
|
#ifdef _XREADER_DEBUG
|
|
|
|
os::Printer::log("CXFileReader: reading texture filename");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!readHeadOfDataObject())
|
|
|
|
{
|
|
|
|
os::Printer::log("No opening brace in Texture filename found in x file", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!getNextTokenAsString(texturename))
|
|
|
|
{
|
|
|
|
os::Printer::log("Unknown syntax while reading texture filename string in x file", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-09-10 09:15:36 -07:00
|
|
|
if (!checkForClosingBrace())
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
|
|
|
os::Printer::log("No closing brace in Texture filename found in x file", ELL_WARNING);
|
2009-02-18 13:25:13 -08:00
|
|
|
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
2007-09-04 11:51:42 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CXMeshFileLoader::parseUnknownDataObject()
|
|
|
|
{
|
|
|
|
// find opening delimiter
|
|
|
|
while(true)
|
|
|
|
{
|
|
|
|
core::stringc t = getNextToken();
|
|
|
|
|
|
|
|
if (t.size() == 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (t == "{")
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2007-09-12 10:45:29 -07:00
|
|
|
u32 counter = 1;
|
2007-09-04 11:51:42 -07:00
|
|
|
|
|
|
|
// parse until closing delimiter
|
|
|
|
|
|
|
|
while(counter)
|
|
|
|
{
|
|
|
|
core::stringc t = getNextToken();
|
|
|
|
|
|
|
|
if (t.size() == 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (t == "{")
|
|
|
|
++counter;
|
|
|
|
else
|
|
|
|
if (t == "}")
|
|
|
|
--counter;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-10 09:15:36 -07:00
|
|
|
//! checks for closing curly brace, returns false if not there
|
|
|
|
bool CXMeshFileLoader::checkForClosingBrace()
|
|
|
|
{
|
|
|
|
return (getNextToken() == "}");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//! checks for one following semicolon, returns false if not there
|
2007-09-04 11:51:42 -07:00
|
|
|
bool CXMeshFileLoader::checkForOneFollowingSemicolons()
|
|
|
|
{
|
2007-09-06 16:20:02 -07:00
|
|
|
if (BinaryFormat)
|
2007-09-04 11:51:42 -07:00
|
|
|
return true;
|
|
|
|
|
2009-02-18 13:25:13 -08:00
|
|
|
if (getNextToken() == ";")
|
|
|
|
return true;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
--P;
|
|
|
|
return false;
|
|
|
|
}
|
2007-09-04 11:51:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//! checks for two following semicolons, returns false if they are not there
|
|
|
|
bool CXMeshFileLoader::checkForTwoFollowingSemicolons()
|
|
|
|
{
|
2007-09-06 16:20:02 -07:00
|
|
|
if (BinaryFormat)
|
2007-09-04 11:51:42 -07:00
|
|
|
return true;
|
|
|
|
|
2007-09-12 10:45:29 -07:00
|
|
|
for (u32 k=0; k<2; ++k)
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
2007-09-10 06:11:47 -07:00
|
|
|
if (getNextToken() != ";")
|
2009-02-18 13:25:13 -08:00
|
|
|
{
|
|
|
|
--P;
|
2007-09-04 11:51:42 -07:00
|
|
|
return false;
|
2009-02-18 13:25:13 -08:00
|
|
|
}
|
2007-09-04 11:51:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//! reads header of dataobject including the opening brace.
|
|
|
|
//! returns false if error happened, and writes name of object
|
|
|
|
//! if there is one
|
|
|
|
bool CXMeshFileLoader::readHeadOfDataObject(core::stringc* outname)
|
|
|
|
{
|
|
|
|
core::stringc nameOrBrace = getNextToken();
|
|
|
|
if (nameOrBrace != "{")
|
|
|
|
{
|
|
|
|
if (outname)
|
|
|
|
(*outname) = nameOrBrace;
|
|
|
|
|
|
|
|
if (getNextToken() != "{")
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//! returns next parseable token. Returns empty string if no token there
|
|
|
|
core::stringc CXMeshFileLoader::getNextToken()
|
|
|
|
{
|
|
|
|
core::stringc s;
|
|
|
|
|
|
|
|
// process binary-formatted file
|
2007-09-06 16:20:02 -07:00
|
|
|
if (BinaryFormat)
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
|
|
|
// in binary mode it will only return NAME and STRING token
|
|
|
|
// and (correctly) skip over other tokens.
|
|
|
|
|
|
|
|
s16 tok = readBinWord();
|
2007-09-12 10:45:29 -07:00
|
|
|
u32 len;
|
2007-09-04 11:51:42 -07:00
|
|
|
|
|
|
|
// standalone tokens
|
|
|
|
switch (tok) {
|
|
|
|
case 1:
|
|
|
|
// name token
|
|
|
|
len = readBinDWord();
|
|
|
|
s = core::stringc(P, len);
|
|
|
|
P += len;
|
|
|
|
return s;
|
|
|
|
case 2:
|
|
|
|
// string token
|
|
|
|
len = readBinDWord();
|
|
|
|
s = core::stringc(P, len);
|
|
|
|
P += (len + 2);
|
|
|
|
return s;
|
|
|
|
case 3:
|
|
|
|
// integer token
|
|
|
|
P += 4;
|
|
|
|
return "<integer>";
|
|
|
|
case 5:
|
|
|
|
// GUID token
|
|
|
|
P += 16;
|
|
|
|
return "<guid>";
|
|
|
|
case 6:
|
|
|
|
len = readBinDWord();
|
|
|
|
P += (len * 4);
|
|
|
|
return "<int_list>";
|
|
|
|
case 7:
|
|
|
|
len = readBinDWord();
|
|
|
|
P += (len * FloatSize);
|
|
|
|
return "<flt_list>";
|
|
|
|
case 0x0a:
|
|
|
|
return "{";
|
|
|
|
case 0x0b:
|
|
|
|
return "}";
|
|
|
|
case 0x0c:
|
|
|
|
return "(";
|
|
|
|
case 0x0d:
|
|
|
|
return ")";
|
|
|
|
case 0x0e:
|
|
|
|
return "[";
|
|
|
|
case 0x0f:
|
|
|
|
return "]";
|
|
|
|
case 0x10:
|
|
|
|
return "<";
|
|
|
|
case 0x11:
|
|
|
|
return ">";
|
|
|
|
case 0x12:
|
|
|
|
return ".";
|
|
|
|
case 0x13:
|
|
|
|
return ",";
|
|
|
|
case 0x14:
|
|
|
|
return ";";
|
|
|
|
case 0x1f:
|
|
|
|
return "template";
|
|
|
|
case 0x28:
|
|
|
|
return "WORD";
|
|
|
|
case 0x29:
|
|
|
|
return "DWORD";
|
|
|
|
case 0x2a:
|
|
|
|
return "FLOAT";
|
|
|
|
case 0x2b:
|
|
|
|
return "DOUBLE";
|
|
|
|
case 0x2c:
|
|
|
|
return "CHAR";
|
|
|
|
case 0x2d:
|
|
|
|
return "UCHAR";
|
|
|
|
case 0x2e:
|
|
|
|
return "SWORD";
|
|
|
|
case 0x2f:
|
|
|
|
return "SDWORD";
|
|
|
|
case 0x30:
|
|
|
|
return "void";
|
|
|
|
case 0x31:
|
|
|
|
return "string";
|
|
|
|
case 0x32:
|
|
|
|
return "unicode";
|
2007-09-10 06:11:47 -07:00
|
|
|
case 0x33:
|
|
|
|
return "cstring";
|
2007-09-04 11:51:42 -07:00
|
|
|
case 0x34:
|
|
|
|
return "array";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// process text-formatted file
|
|
|
|
else
|
|
|
|
{
|
|
|
|
findNextNoneWhiteSpace();
|
|
|
|
|
|
|
|
if (P >= End)
|
|
|
|
return s;
|
|
|
|
|
2007-09-09 15:40:28 -07:00
|
|
|
while((P < End) && !core::isspace(P[0]))
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
2007-09-09 15:40:28 -07:00
|
|
|
// either keep token delimiters when already holding a token, or return if first valid char
|
|
|
|
if (P[0]==';' || P[0]=='}' || P[0]=='{' || P[0]==',')
|
|
|
|
{
|
|
|
|
if (!s.size())
|
|
|
|
{
|
|
|
|
s.append(P[0]);
|
|
|
|
++P;
|
|
|
|
}
|
|
|
|
break; // stop for delimiter
|
|
|
|
}
|
2007-09-04 11:51:42 -07:00
|
|
|
s.append(P[0]);
|
|
|
|
++P;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//! places pointer to next begin of a token, which must be a number,
|
|
|
|
// and ignores comments
|
|
|
|
void CXMeshFileLoader::findNextNoneWhiteSpaceNumber()
|
|
|
|
{
|
2007-09-06 16:20:02 -07:00
|
|
|
if (BinaryFormat)
|
2007-09-04 11:51:42 -07:00
|
|
|
return;
|
|
|
|
|
2008-10-01 04:36:20 -07:00
|
|
|
while((P < End) && (P[0] != '-') && (P[0] != '.') &&
|
|
|
|
!( core::isdigit(P[0])))
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
|
|
|
// check if this is a comment
|
|
|
|
if ((P[0] == '/' && P[1] == '/') || P[0] == '#')
|
|
|
|
readUntilEndOfLine();
|
|
|
|
else
|
2008-10-01 04:36:20 -07:00
|
|
|
++P;
|
2007-09-04 11:51:42 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-09 16:09:06 -07:00
|
|
|
|
2007-09-04 11:51:42 -07:00
|
|
|
// places pointer to next begin of a token, and ignores comments
|
|
|
|
void CXMeshFileLoader::findNextNoneWhiteSpace()
|
|
|
|
{
|
2007-09-06 16:20:02 -07:00
|
|
|
if (BinaryFormat)
|
2007-09-04 11:51:42 -07:00
|
|
|
return;
|
|
|
|
|
|
|
|
while(true)
|
|
|
|
{
|
2007-09-09 15:40:28 -07:00
|
|
|
while((P < End) && core::isspace(P[0]))
|
2008-10-22 02:23:31 -07:00
|
|
|
{
|
|
|
|
if (*P=='\n')
|
|
|
|
++Line;
|
2007-09-04 11:51:42 -07:00
|
|
|
++P;
|
2008-10-22 02:23:31 -07:00
|
|
|
}
|
2007-09-04 11:51:42 -07:00
|
|
|
|
|
|
|
if (P >= End)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// check if this is a comment
|
|
|
|
if ((P[0] == '/' && P[1] == '/') ||
|
|
|
|
P[0] == '#')
|
|
|
|
readUntilEndOfLine();
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//! reads a x file style string
|
|
|
|
bool CXMeshFileLoader::getNextTokenAsString(core::stringc& out)
|
|
|
|
{
|
2007-09-06 16:20:02 -07:00
|
|
|
if (BinaryFormat)
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
|
|
|
out=getNextToken();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
findNextNoneWhiteSpace();
|
|
|
|
|
|
|
|
if (P >= End)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (P[0] != '"')
|
|
|
|
return false;
|
|
|
|
++P;
|
|
|
|
|
|
|
|
while(P < End && P[0]!='"')
|
|
|
|
{
|
|
|
|
out.append(P[0]);
|
|
|
|
++P;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( P[1] != ';' || P[0] != '"')
|
|
|
|
return false;
|
|
|
|
P+=2;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CXMeshFileLoader::readUntilEndOfLine()
|
|
|
|
{
|
2007-09-06 16:20:02 -07:00
|
|
|
if (BinaryFormat)
|
2007-09-04 11:51:42 -07:00
|
|
|
return;
|
|
|
|
|
|
|
|
while(P < End)
|
|
|
|
{
|
2007-09-09 15:40:28 -07:00
|
|
|
if (P[0] == '\n' || P[0] == '\r')
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
|
|
|
++P;
|
2008-10-22 02:23:31 -07:00
|
|
|
++Line;
|
2007-09-04 11:51:42 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
++P;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
u16 CXMeshFileLoader::readBinWord()
|
|
|
|
{
|
2009-07-02 02:39:50 -07:00
|
|
|
#ifdef __BIG_ENDIAN__
|
|
|
|
const u16 tmp = os::Byteswap::byteswap(*(u16 *)P);
|
|
|
|
#else
|
|
|
|
const u16 tmp = *(u16 *)P;
|
|
|
|
#endif
|
2007-09-04 11:51:42 -07:00
|
|
|
P += 2;
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
u32 CXMeshFileLoader::readBinDWord()
|
|
|
|
{
|
2009-07-02 02:39:50 -07:00
|
|
|
#ifdef __BIG_ENDIAN__
|
|
|
|
const u32 tmp = os::Byteswap::byteswap(*(u32 *)P);
|
|
|
|
#else
|
|
|
|
const u32 tmp = *(u32 *)P;
|
|
|
|
#endif
|
2007-09-04 11:51:42 -07:00
|
|
|
P += 4;
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-12 10:45:29 -07:00
|
|
|
u32 CXMeshFileLoader::readInt()
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
2007-09-06 16:20:02 -07:00
|
|
|
if (BinaryFormat)
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
2007-09-06 16:20:02 -07:00
|
|
|
if (!BinaryNumCount)
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
2009-07-02 02:39:50 -07:00
|
|
|
const u16 tmp = readBinWord(); // 0x06 or 0x03
|
2007-09-10 06:11:47 -07:00
|
|
|
if (tmp == 0x06)
|
|
|
|
BinaryNumCount = readBinDWord();
|
|
|
|
else
|
|
|
|
BinaryNumCount = 1; // single int
|
2007-09-04 11:51:42 -07:00
|
|
|
}
|
2007-09-06 16:20:02 -07:00
|
|
|
--BinaryNumCount;
|
2007-09-04 11:51:42 -07:00
|
|
|
return readBinDWord();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
findNextNoneWhiteSpaceNumber();
|
2007-09-12 10:45:29 -07:00
|
|
|
return core::strtol10(P, &P);
|
2007-09-04 11:51:42 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
f32 CXMeshFileLoader::readFloat()
|
|
|
|
{
|
2007-09-06 16:20:02 -07:00
|
|
|
if (BinaryFormat)
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
2007-09-10 06:11:47 -07:00
|
|
|
if (!BinaryNumCount)
|
|
|
|
{
|
2009-07-02 02:39:50 -07:00
|
|
|
const u16 tmp = readBinWord(); // 0x07 or 0x42
|
2007-09-10 06:11:47 -07:00
|
|
|
if (tmp == 0x07)
|
|
|
|
BinaryNumCount = readBinDWord();
|
|
|
|
else
|
|
|
|
BinaryNumCount = 1; // single int
|
|
|
|
}
|
|
|
|
--BinaryNumCount;
|
2007-09-04 11:51:42 -07:00
|
|
|
if (FloatSize == 8)
|
|
|
|
{
|
2009-07-02 02:39:50 -07:00
|
|
|
#ifdef __BIG_ENDIAN__
|
|
|
|
c8 ctmp[8];
|
|
|
|
*((f32*)(ctmp+4)) = os::Byteswap::byteswap(*(f32 *)P);
|
|
|
|
*((f32*)(ctmp)) = os::Byteswap::byteswap(*(f32 *)P+4);
|
|
|
|
const f32 tmp = (f32)(*(f64 *)ctmp);
|
|
|
|
#else
|
|
|
|
const f32 tmp = (f32)(*(f64 *)P);
|
|
|
|
#endif
|
2007-09-04 11:51:42 -07:00
|
|
|
P += 8;
|
2009-07-02 02:39:50 -07:00
|
|
|
return tmp;
|
2007-09-04 11:51:42 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-07-02 02:39:50 -07:00
|
|
|
#ifdef __BIG_ENDIAN__
|
|
|
|
const f32 tmp = os::Byteswap::byteswap(*(f32 *)P);
|
|
|
|
#else
|
|
|
|
const f32 tmp = *(f32 *)P;
|
|
|
|
#endif
|
2007-09-04 11:51:42 -07:00
|
|
|
P += 4;
|
2009-07-02 02:39:50 -07:00
|
|
|
return tmp;
|
2007-09-04 11:51:42 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
findNextNoneWhiteSpaceNumber();
|
|
|
|
f32 ftmp;
|
|
|
|
P = core::fast_atof_move(P, ftmp);
|
|
|
|
return ftmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// read 2-dimensional vector. Stops at semicolon after second value for text file format
|
|
|
|
bool CXMeshFileLoader::readVector2(core::vector2df& vec)
|
|
|
|
{
|
|
|
|
vec.X = readFloat();
|
|
|
|
vec.Y = readFloat();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// read 3-dimensional vector. Stops at semicolon after third value for text file format
|
|
|
|
bool CXMeshFileLoader::readVector3(core::vector3df& vec)
|
|
|
|
{
|
|
|
|
vec.X = readFloat();
|
|
|
|
vec.Y = readFloat();
|
|
|
|
vec.Z = readFloat();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// read color without alpha value. Stops after second semicolon after blue value
|
|
|
|
bool CXMeshFileLoader::readRGB(video::SColor& color)
|
|
|
|
{
|
2008-02-12 07:32:39 -08:00
|
|
|
video::SColorf tmpColor;
|
|
|
|
tmpColor.r = readFloat();
|
|
|
|
tmpColor.g = readFloat();
|
|
|
|
tmpColor.b = readFloat();
|
|
|
|
color = tmpColor.toSColor();
|
2007-09-04 11:51:42 -07:00
|
|
|
return checkForOneFollowingSemicolons();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// read color with alpha value. Stops after second semicolon after blue value
|
|
|
|
bool CXMeshFileLoader::readRGBA(video::SColor& color)
|
|
|
|
{
|
2008-02-12 07:32:39 -08:00
|
|
|
video::SColorf tmpColor;
|
|
|
|
tmpColor.r = readFloat();
|
|
|
|
tmpColor.g = readFloat();
|
|
|
|
tmpColor.b = readFloat();
|
|
|
|
tmpColor.a = readFloat();
|
|
|
|
color = tmpColor.toSColor();
|
|
|
|
return checkForOneFollowingSemicolons();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// read matrix from list of floats
|
|
|
|
bool CXMeshFileLoader::readMatrix(core::matrix4& mat)
|
|
|
|
{
|
|
|
|
for (u32 i=0; i<16; ++i)
|
|
|
|
mat[i] = readFloat();
|
2007-09-04 11:51:42 -07:00
|
|
|
return checkForOneFollowingSemicolons();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} // end namespace scene
|
|
|
|
} // end namespace irr
|
|
|
|
|
|
|
|
#endif // _IRR_COMPILE_WITH_X_LOADER_
|
2007-05-20 11:03:49 -07:00
|
|
|
|