Removed unnecessary irr namespace prefixing.
Added STL mesh file format reader and writer. This is a pretty simple format, but I wanted to try the mesh writer interface. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@983 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
240c64cd4f
commit
df946a1ce6
|
@ -4,6 +4,8 @@ Changes in version 1.4 (... 2007)
|
|||
|
||||
- Major API rewriting for proper const usage. Now, most getter methods are const and so are the larger parameters and return values. Moreover, mayn methods taking only unsigned numbers now use u32 instead of s32 to get his limitation from the method's signature.
|
||||
|
||||
- Added STL mesh file format reader and writer.
|
||||
|
||||
- Added IMeshManipulator::createMeshWelded which creates a copy of the mesh with similar vertices welded together.
|
||||
|
||||
- Irrlicht now has its own file format for static meshes. It is based on xml and has the
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
// Copyright (C) 2002-2007 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#ifndef __E_MESH_WRITER_ENUMS_H_INCLUDED__
|
||||
#define __E_MESH_WRITER_ENUMS_H_INCLUDED__
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace scene
|
||||
{
|
||||
|
||||
|
||||
//! An enumeration for all supported types of built-in mesh writers
|
||||
/** A scene mesh writers is represented by a four character code
|
||||
such as 'irrm' or 'coll' instead of simple numbers, to avoid
|
||||
name clashes with external mesh writers.*/
|
||||
enum EMESH_WRITER_TYPE
|
||||
{
|
||||
//! Irrlicht Native mesh writer, for static .irrmesh files.
|
||||
EMWT_IRR_MESH = MAKE_IRR_ID('i','r','r','m'),
|
||||
|
||||
//! COLLADA mesh writer for .dae and .xml files
|
||||
EMWT_COLLADA = MAKE_IRR_ID('c','o','l','l'),
|
||||
|
||||
//! STL mesh writer for .stl files
|
||||
EMWT_STL = MAKE_IRR_ID('s','t','l',0)
|
||||
};
|
||||
|
||||
|
||||
//! flags configuring mesh writing
|
||||
enum E_MESH_WRITER_FLAGS
|
||||
{
|
||||
//! no writer flags
|
||||
EMWF_NONE = 0,
|
||||
|
||||
//! write lightmap textures out if possible
|
||||
EMWF_WRITE_LIGHTMAPS = 0x1,
|
||||
|
||||
//! write in a way that does consume less disk space
|
||||
EMWF_WRITE_COMPRESSED = 0x2
|
||||
};
|
||||
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
||||
|
||||
|
||||
#endif // __E_MESH_WRITER_ENUMS_H_INCLUDED__
|
||||
|
|
@ -158,7 +158,7 @@ public:
|
|||
//! the name specified using elementName.
|
||||
//! \param elementName: The surrounding element name. If it is null, the default one, "attributes" will be taken.
|
||||
//! If set to false, the first appearing list of attributes are read.
|
||||
virtual bool read(irr::io::IXMLReader* reader, bool readCurrentElementOnly=false, const wchar_t* elementName=0) = 0;
|
||||
virtual bool read(io::IXMLReader* reader, bool readCurrentElementOnly=false, const wchar_t* elementName=0) = 0;
|
||||
|
||||
//! Write these attributes into a xml file
|
||||
//! \param writer: The XML writer to write to
|
||||
|
|
|
@ -34,10 +34,10 @@ public:
|
|||
virtual bool isALoadableFileExtension(const c8* fileName) const = 0;
|
||||
|
||||
//! returns true if the file maybe is able to be loaded by this class
|
||||
virtual bool isALoadableFileFormat(irr::io::IReadFile* file) const = 0;
|
||||
virtual bool isALoadableFileFormat(io::IReadFile* file) const = 0;
|
||||
|
||||
//! creates a surface from the file
|
||||
virtual IImage* loadImage(irr::io::IReadFile* file) const = 0;
|
||||
virtual IImage* loadImage(io::IReadFile* file) const = 0;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ public:
|
|||
/** \return Pointer to the created mesh. Returns 0 if loading failed.
|
||||
If you no longer need the mesh, you should call IAnimatedMesh::drop().
|
||||
See IReferenceCounted::drop() for more information. */
|
||||
virtual IAnimatedMesh* createMesh(irr::io::IReadFile* file) = 0;
|
||||
virtual IAnimatedMesh* createMesh(io::IReadFile* file) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -2,48 +2,21 @@
|
|||
#define __IRR_I_MESH_WRITER_H_INCLUDED__
|
||||
|
||||
#include "IReferenceCounted.h"
|
||||
#include "IWriteFile.h"
|
||||
#include "irrTypes.h"
|
||||
#include "EMeshWriterEnums.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
class IrrlichtDevice;
|
||||
namespace io
|
||||
{
|
||||
class IWriteFile;
|
||||
} // end namespace io
|
||||
|
||||
namespace scene
|
||||
{
|
||||
class IMesh;
|
||||
|
||||
//! An enumeration for all supported types of built-in mesh writers
|
||||
/** A scene mesh writers is represented by a four character code
|
||||
such as 'irrm' or 'coll' instead of simple numbers, to avoid
|
||||
name clashes with external mesh writers.*/
|
||||
enum EMESH_WRITER_TYPE
|
||||
{
|
||||
//! Irrlicht Native mesh writer, for static .irrmesh files.
|
||||
EMWT_IRR_MESH = MAKE_IRR_ID('i','r','r','m'),
|
||||
|
||||
//! COLLADA mesh writer for .dae and .xml files
|
||||
EMWT_COLLADA = MAKE_IRR_ID('c','o','l','l'),
|
||||
|
||||
//! STL mesh writer for .stl files
|
||||
EMWT_STL = MAKE_IRR_ID('s','t','l',0)
|
||||
};
|
||||
|
||||
|
||||
//! flags configuring mesh writing
|
||||
enum E_MESH_WRITER_FLAGS
|
||||
{
|
||||
//! no writer flags
|
||||
EMWF_NONE = 0,
|
||||
|
||||
//! write lightmap textures out if possible
|
||||
EMWF_WRITE_LIGHTMAPS = 0x1
|
||||
};
|
||||
|
||||
|
||||
|
||||
// interface for writing meshes
|
||||
class IMeshWriter : public virtual irr::IReferenceCounted
|
||||
class IMeshWriter : public virtual IReferenceCounted
|
||||
{
|
||||
public:
|
||||
|
||||
|
|
|
@ -31,13 +31,13 @@ public:
|
|||
//! gets the processor speed in megahertz
|
||||
//! \param MHz: The integer variable to store the speed in.
|
||||
//! \return Returns true if successful, false if not
|
||||
virtual bool getProcessorSpeedMHz(irr::u32* MHz) const = 0;
|
||||
virtual bool getProcessorSpeedMHz(u32* MHz) const = 0;
|
||||
|
||||
//! gets the total and available system RAM
|
||||
//! \param Total: will contain the total system memory
|
||||
//! \param Avail: will contain the available memory
|
||||
//! \return Returns true if successful, false if not
|
||||
virtual bool getSystemMemory(irr::u32* Total, irr::u32* Avail) const = 0;
|
||||
virtual bool getSystemMemory(u32* Total, u32* Avail) const = 0;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -575,7 +575,7 @@ namespace quake3
|
|||
video::ITexture* texture = 0;
|
||||
for ( u32 g = 0; g != 2 ; ++g )
|
||||
{
|
||||
irr::core::cutFilenameExtension ( loadFile, stringList[i] ).append ( extension[g] );
|
||||
core::cutFilenameExtension ( loadFile, stringList[i] ).append ( extension[g] );
|
||||
|
||||
if ( fileSystem->existFile ( loadFile.c_str() ) )
|
||||
{
|
||||
|
@ -595,7 +595,7 @@ namespace quake3
|
|||
/*!
|
||||
Manages various Quake3 Shader Styles
|
||||
*/
|
||||
class IShaderManager : public irr::IReferenceCounted
|
||||
class IShaderManager : public IReferenceCounted
|
||||
{
|
||||
};
|
||||
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
#include "SColor.h"
|
||||
#include "ETerrainElements.h"
|
||||
#include "ESceneNodeTypes.h"
|
||||
#include "EMeshWriterEnums.h"
|
||||
#include "SceneParameters.h"
|
||||
#include "IMeshWriter.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
|
@ -45,6 +45,8 @@ namespace video
|
|||
|
||||
namespace scene
|
||||
{
|
||||
class IMeshWriter;
|
||||
|
||||
//! Enumeration for render passes.
|
||||
/** A parameter passed to the registerNodeForRendering() method of the ISceneManager,
|
||||
specifying when the mode wants to be drawn in relation to the other nodes. */
|
||||
|
|
|
@ -100,7 +100,7 @@ define out. */
|
|||
//! to remove the dependencies such that Irrlicht will compile on those systems, too.
|
||||
#if defined(_IRR_LINUX_PLATFORM_)
|
||||
#define _IRR_LINUX_X11_VIDMODE_
|
||||
//#define _IRR_LINUX_X11_RANDR_
|
||||
#define _IRR_LINUX_X11_RANDR_
|
||||
#endif
|
||||
|
||||
//! Define _IRR_COMPILE_WITH_GUI_ to compile the engine with the built-in GUI
|
||||
|
@ -255,6 +255,15 @@ B3D, MS3D or X meshes */
|
|||
#define _IRR_COMPILE_WITH_OCT_LOADER_
|
||||
//! Define _IRR_COMPILE_WITH_OGRE_LOADER_ if you want to load Ogre 3D files
|
||||
#define _IRR_COMPILE_WITH_OGRE_LOADER_
|
||||
//! Define _IRR_COMPILE_WITH_STL_LOADER_ if you want to load .stl files
|
||||
#define _IRR_COMPILE_WITH_STL_LOADER_
|
||||
|
||||
//! Define _IRR_COMPILE_WITH_IRR_WRITER_ if you want to write static .irr files
|
||||
#define _IRR_COMPILE_WITH_IRR_WRITER_
|
||||
//! Define _IRR_COMPILE_WITH_COLLADA_WRITER_ if you want to write Collada files
|
||||
#define _IRR_COMPILE_WITH_COLLADA_WRITER_
|
||||
//! Define _IRR_COMPILE_WITH_STL_WRITER_ if you want to write .stl files
|
||||
#define _IRR_COMPILE_WITH_STL_WRITER_
|
||||
|
||||
//! Set FPU settings
|
||||
/** Irrlicht should use approximate float and integer fpu techniques
|
||||
|
|
|
@ -863,7 +863,7 @@ private:
|
|||
|
||||
|
||||
//! Typedef for character strings
|
||||
typedef string<irr::c8> stringc;
|
||||
typedef string<c8> stringc;
|
||||
|
||||
//! Typedef for wide character strings
|
||||
typedef string<wchar_t> stringw;
|
||||
|
|
|
@ -37,7 +37,7 @@ public:
|
|||
//! \return Pointer to the created mesh. Returns 0 if loading failed.
|
||||
//! If you no longer need the mesh, you should call IAnimatedMesh::drop().
|
||||
//! See IReferenceCounted::drop() for more information.
|
||||
virtual IAnimatedMesh* createMesh(irr::io::IReadFile* file);
|
||||
virtual IAnimatedMesh* createMesh(io::IReadFile* file);
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -228,7 +228,7 @@ void CAnimatedMeshSceneNode::OnAnimate(u32 timeMs)
|
|||
angle = dotproduct ( v(0,1,0), up )
|
||||
axis = crossproduct ( v(0,1,0), up )
|
||||
*/
|
||||
inline void AlignToUpVector(irr::core::matrix4 &m, const irr::core::vector3df &up )
|
||||
inline void AlignToUpVector(core::matrix4 &m, const core::vector3df &up )
|
||||
{
|
||||
core::quaternion quatRot( up.Z, 0.f, -up.X, 1 + up.Y );
|
||||
quatRot.normalize();
|
||||
|
|
|
@ -1317,7 +1317,7 @@ void CAttributes::setAttribute(s32 index, void* userPointer)
|
|||
//! Reads attributes from a xml file.
|
||||
//! \param readCurrentElementOnly: If set to true, reading only works if current element has the name 'attributes'.
|
||||
//! IF set to false, the first appearing list attributes are read.
|
||||
bool CAttributes::read(irr::io::IXMLReader* reader, bool readCurrentElementOnly,
|
||||
bool CAttributes::read(io::IXMLReader* reader, bool readCurrentElementOnly,
|
||||
const wchar_t* nonDefaultElementName)
|
||||
{
|
||||
if (!reader)
|
||||
|
|
|
@ -62,7 +62,7 @@ public:
|
|||
//! Reads attributes from a xml file.
|
||||
//! \param readCurrentElementOnly: If set to true, reading only works if current element has the name 'attributes'.
|
||||
//! IF set to false, the first appearing list attributes are read.
|
||||
virtual bool read(irr::io::IXMLReader* reader, bool readCurrentElementOnly=false,
|
||||
virtual bool read(io::IXMLReader* reader, bool readCurrentElementOnly=false,
|
||||
const wchar_t* nonDefaultElementName = 0);
|
||||
|
||||
//! Write these attributes into a xml file
|
||||
|
|
|
@ -47,7 +47,7 @@ bool CB3DMeshFileLoader::isALoadableFileExtension(const c8* fileName) const
|
|||
//! \return Pointer to the created mesh. Returns 0 if loading failed.
|
||||
//! If you no longer need the mesh, you should call IAnimatedMesh::drop().
|
||||
//! See IReferenceCounted::drop() for more information.
|
||||
IAnimatedMesh* CB3DMeshFileLoader::createMesh(irr::io::IReadFile* f)
|
||||
IAnimatedMesh* CB3DMeshFileLoader::createMesh(io::IReadFile* f)
|
||||
{
|
||||
if (!f)
|
||||
return 0;
|
||||
|
@ -211,9 +211,11 @@ bool CB3DMeshFileLoader::readChunkNODE(CSkinnedMesh::SJoint *InJoint)
|
|||
|
||||
//Build LocalMatrix:
|
||||
|
||||
irr::core::matrix4 positionMatrix; positionMatrix.setTranslation( Joint->Animatedposition );
|
||||
irr::core::matrix4 scaleMatrix; scaleMatrix.setScale( Joint->Animatedscale );
|
||||
irr::core::matrix4 rotationMatrix = Joint->Animatedrotation.getMatrix();
|
||||
core::matrix4 positionMatrix;
|
||||
positionMatrix.setTranslation( Joint->Animatedposition );
|
||||
core::matrix4 scaleMatrix;
|
||||
scaleMatrix.setScale( Joint->Animatedscale );
|
||||
core::matrix4 rotationMatrix = Joint->Animatedrotation.getMatrix();
|
||||
|
||||
Joint->LocalMatrix = positionMatrix * rotationMatrix * scaleMatrix;
|
||||
|
||||
|
@ -601,7 +603,7 @@ bool CB3DMeshFileLoader::readChunkTRIS(CSkinnedMesh::SJoint *InJoint, scene::SSk
|
|||
if (B3dMaterial)
|
||||
{
|
||||
// Apply Material/Colour/etc...
|
||||
irr::video::S3DVertex *Vertex=MeshBuffer->getVertex(MeshBuffer->getVertexCount()-1);
|
||||
video::S3DVertex *Vertex=MeshBuffer->getVertex(MeshBuffer->getVertexCount()-1);
|
||||
|
||||
if (Vertex->Color.getAlpha() == 255) //Note: Irrlicht docs state that 0 is opaque, are they wrong?
|
||||
Vertex->Color.setAlpha( (s32)(B3dMaterial->alpha * 255.0f) );
|
||||
|
@ -815,7 +817,7 @@ bool CB3DMeshFileLoader::readChunkBRUS()
|
|||
|
||||
SB3dMaterial B3dMaterial;
|
||||
|
||||
B3dMaterial.Material = new irr::video::SMaterial();
|
||||
B3dMaterial.Material = new video::SMaterial();
|
||||
B3dMaterial.Textures[0]=0;
|
||||
B3dMaterial.Textures[1]=0;
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ private:
|
|||
|
||||
struct SB3dTexture
|
||||
{
|
||||
irr::video::ITexture* Texture;
|
||||
video::ITexture* Texture;
|
||||
s32 Flags;
|
||||
s32 Blend;
|
||||
f32 Xpos;
|
||||
|
@ -66,7 +66,7 @@ private:
|
|||
|
||||
struct SB3dMaterial
|
||||
{
|
||||
irr::video::SMaterial* Material;
|
||||
video::SMaterial* Material;
|
||||
f32 red, green, blue, alpha;
|
||||
f32 shininess;
|
||||
s32 blend,fx;
|
||||
|
|
|
@ -48,7 +48,7 @@ bool CBSPMeshFileLoader::isALoadableFileExtension(const c8* filename) const
|
|||
//! \return Pointer to the created mesh. Returns 0 if loading failed.
|
||||
//! If you no longer need the mesh, you should call IAnimatedMesh::drop().
|
||||
//! See IReferenceCounted::drop() for more information.
|
||||
IAnimatedMesh* CBSPMeshFileLoader::createMesh(irr::io::IReadFile* file)
|
||||
IAnimatedMesh* CBSPMeshFileLoader::createMesh(io::IReadFile* file)
|
||||
{
|
||||
// load quake 3 bsp
|
||||
if (strstr(file->getFileName(), ".bsp"))
|
||||
|
|
|
@ -34,7 +34,7 @@ public:
|
|||
//! \return Pointer to the created mesh. Returns 0 if loading failed.
|
||||
//! If you no longer need the mesh, you should call IAnimatedMesh::drop().
|
||||
//! See IReferenceCounted::drop() for more information.
|
||||
virtual IAnimatedMesh* createMesh(irr::io::IReadFile* file);
|
||||
virtual IAnimatedMesh* createMesh(io::IReadFile* file);
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -374,7 +374,7 @@ namespace scene
|
|||
}
|
||||
|
||||
//! creates/loads an animated mesh from the file.
|
||||
IAnimatedMesh* CCSMLoader::createMesh(irr::io::IReadFile* file)
|
||||
IAnimatedMesh* CCSMLoader::createMesh(io::IReadFile* file)
|
||||
{
|
||||
file->grab(); // originally, this loader created the file on its own.
|
||||
|
||||
|
@ -392,7 +392,7 @@ namespace scene
|
|||
return am;
|
||||
}
|
||||
|
||||
scene::IMesh* CCSMLoader::createCSMMesh(irr::io::IReadFile* file)
|
||||
scene::IMesh* CCSMLoader::createCSMMesh(io::IReadFile* file)
|
||||
{
|
||||
if (!file)
|
||||
return 0;
|
||||
|
|
|
@ -63,11 +63,11 @@ namespace scene
|
|||
virtual bool isALoadableFileExtension(const c8* fileName) const;
|
||||
|
||||
//! creates/loads an animated mesh from the file.
|
||||
virtual IAnimatedMesh* createMesh(irr::io::IReadFile* file);
|
||||
virtual IAnimatedMesh* createMesh(io::IReadFile* file);
|
||||
|
||||
private:
|
||||
|
||||
scene::IMesh* createCSMMesh(irr::io::IReadFile* file);
|
||||
scene::IMesh* createCSMMesh(io::IReadFile* file);
|
||||
|
||||
scene::IMesh* createIrrlichtMesh(const CSMFile* csmFile,
|
||||
core::stringc textureRoot, const c8* lmprefix);
|
||||
|
|
|
@ -216,7 +216,7 @@ bool CColladaFileLoader::isALoadableFileExtension(const c8* fileName) const
|
|||
//! \return Pointer to the created mesh. Returns 0 if loading failed.
|
||||
//! If you no longer need the mesh, you should call IAnimatedMesh::drop().
|
||||
//! See IReferenceCounted::drop() for more information.
|
||||
IAnimatedMesh* CColladaFileLoader::createMesh(irr::io::IReadFile* file)
|
||||
IAnimatedMesh* CColladaFileLoader::createMesh(io::IReadFile* file)
|
||||
{
|
||||
io::IXMLReaderUTF8* reader = FileSystem->createXMLReaderUTF8(file);
|
||||
if (!reader)
|
||||
|
|
|
@ -162,7 +162,7 @@ public:
|
|||
//! \return Pointer to the created mesh. Returns 0 if loading failed.
|
||||
//! If you no longer need the mesh, you should call IAnimatedMesh::drop().
|
||||
//! See IReferenceCounted::drop() for more information.
|
||||
virtual IAnimatedMesh* createMesh(irr::io::IReadFile* file);
|
||||
virtual IAnimatedMesh* createMesh(io::IReadFile* file);
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "CColladaMeshWriter.h"
|
||||
#include "os.h"
|
||||
#include "IFileSystem.h"
|
||||
#include "IWriteFile.h"
|
||||
#include "IXMLWriter.h"
|
||||
#include "IMesh.h"
|
||||
#include "IAttributes.h"
|
||||
|
@ -11,8 +12,8 @@ namespace scene
|
|||
{
|
||||
|
||||
|
||||
CColladaMeshWriter::CColladaMeshWriter(irr::video::IVideoDriver* driver,
|
||||
irr::io::IFileSystem* fs)
|
||||
CColladaMeshWriter::CColladaMeshWriter(video::IVideoDriver* driver,
|
||||
io::IFileSystem* fs)
|
||||
: FileSystem(fs), VideoDriver(driver), Writer(0)
|
||||
{
|
||||
if (VideoDriver)
|
||||
|
@ -102,7 +103,7 @@ bool CColladaMeshWriter::writeMesh(io::IWriteFile* file, scene::IMesh* mesh, s32
|
|||
|
||||
// write all interesting material parameters as parameter
|
||||
|
||||
irr::io::IAttributes* attributes = VideoDriver->createAttributesFromMaterial(
|
||||
io::IAttributes* attributes = VideoDriver->createAttributesFromMaterial(
|
||||
mesh->getMeshBuffer(i)->getMaterial());
|
||||
|
||||
u32 count = attributes->getAttributeCount();
|
||||
|
|
|
@ -22,7 +22,7 @@ class CColladaMeshWriter : public IMeshWriter
|
|||
{
|
||||
public:
|
||||
|
||||
CColladaMeshWriter(irr::video::IVideoDriver* driver, irr::io::IFileSystem* fs);
|
||||
CColladaMeshWriter(video::IVideoDriver* driver, io::IFileSystem* fs);
|
||||
virtual ~CColladaMeshWriter();
|
||||
|
||||
//! Returns the type of the mesh writer
|
||||
|
|
|
@ -144,7 +144,7 @@ void CCubeSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeRea
|
|||
void CCubeSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options)
|
||||
{
|
||||
Size = in->getAttributeAsFloat("Size");
|
||||
Size = irr::core::max_(Size, 0.0001f);
|
||||
Size = core::max_(Size, 0.0001f);
|
||||
setSize();
|
||||
|
||||
ISceneNode::deserializeAttributes(in, options);
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace scene
|
|||
public:
|
||||
|
||||
/** constructor*/
|
||||
CDMFLoader(video::IVideoDriver* driver,irr::scene::ISceneManager* smgr);
|
||||
CDMFLoader(video::IVideoDriver* driver, ISceneManager* smgr);
|
||||
|
||||
/** destructor*/
|
||||
virtual ~CDMFLoader();
|
||||
|
@ -63,13 +63,13 @@ namespace scene
|
|||
\return Pointer to the created mesh. Returns 0 if loading failed.
|
||||
If you no longer need the mesh, you should call IAnimatedMesh::drop().
|
||||
See IReferenceCounted::drop() for more information.*/
|
||||
virtual IAnimatedMesh* createMesh(irr::io::IReadFile* file);
|
||||
virtual IAnimatedMesh* createMesh(io::IReadFile* file);
|
||||
|
||||
/** loads dynamic lights present in this scene.
|
||||
Note that loaded lights from DeleD must have the suffix \b dynamic_ and must be \b pointlight.
|
||||
Irrlicht correctly loads specular color, diffuse color , position and distance of object affected by light.
|
||||
\return number of lights loaded or 0 if loading failed.*/
|
||||
int loadLights(const c8 * filename, irr::scene::ISceneManager* smgr,
|
||||
int loadLights(const c8 * filename, ISceneManager* smgr,
|
||||
ISceneNode* parent = 0, s32 base_id = 1000);
|
||||
|
||||
/** loads water plains present in this scene.
|
||||
|
@ -77,7 +77,7 @@ namespace scene
|
|||
Irrlicht correctly loads position and rotation of water plain as well as texture layers.
|
||||
\return number of water plains loaded or 0 if loading failed.*/
|
||||
int loadWaterPlains ( const c8 *filename,
|
||||
irr::scene::ISceneManager* smgr,
|
||||
ISceneManager* smgr,
|
||||
ISceneNode * parent = 0,
|
||||
s32 base_id = 2000,
|
||||
bool mode = true);
|
||||
|
@ -87,7 +87,7 @@ namespace scene
|
|||
void GetFaceNormal(f32 a[3], f32 b[3], f32 c[3], f32 out[3]);
|
||||
|
||||
video::IVideoDriver* Driver;
|
||||
scene::ISceneManager* SceneMgr;
|
||||
ISceneManager* SceneMgr;
|
||||
};
|
||||
|
||||
} // end namespace scene
|
||||
|
|
|
@ -207,7 +207,7 @@ void CGUIButton::draw()
|
|||
return;
|
||||
|
||||
IGUISkin* skin = Environment->getSkin();
|
||||
irr::video::IVideoDriver* driver = Environment->getVideoDriver();
|
||||
video::IVideoDriver* driver = Environment->getVideoDriver();
|
||||
|
||||
IGUIFont* font = OverrideFont;
|
||||
if (!OverrideFont)
|
||||
|
|
|
@ -196,7 +196,7 @@ void CGUIColorSelectDialog::buildColorRing( const core::dimension2d<s32> & dim,
|
|||
d.Width = dim.Width * supersample;
|
||||
d.Height = dim.Height * supersample;
|
||||
|
||||
RawTexture = new video::CImage ( irr::video::ECF_A8R8G8B8, d );
|
||||
RawTexture = new video::CImage ( video::ECF_A8R8G8B8, d );
|
||||
|
||||
RawTexture->fill ( 0x00808080 );
|
||||
|
||||
|
@ -315,7 +315,7 @@ void CGUIColorSelectDialog::buildColorRing( const core::dimension2d<s32> & dim,
|
|||
|
||||
if ( supersample > 1 )
|
||||
{
|
||||
video::CImage * filter = new video::CImage(irr::video::ECF_A8R8G8B8, dim );
|
||||
video::CImage * filter = new video::CImage(video::ECF_A8R8G8B8, dim );
|
||||
RawTexture->copyToScalingBoxFilter ( filter, 0 );
|
||||
RawTexture->drop ();
|
||||
RawTexture = filter;
|
||||
|
|
|
@ -64,7 +64,7 @@ void CGUIImage::draw()
|
|||
return;
|
||||
|
||||
IGUISkin* skin = Environment->getSkin();
|
||||
irr::video::IVideoDriver* driver = Environment->getVideoDriver();
|
||||
video::IVideoDriver* driver = Environment->getVideoDriver();
|
||||
|
||||
core::rect<s32> rect = AbsoluteRect;
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ void CGUIInOutFader::draw()
|
|||
return;
|
||||
}
|
||||
|
||||
irr::video::IVideoDriver* driver = Environment->getVideoDriver();
|
||||
video::IVideoDriver* driver = Environment->getVideoDriver();
|
||||
|
||||
if (driver)
|
||||
{
|
||||
|
|
|
@ -56,7 +56,7 @@ void CGUIStaticText::draw()
|
|||
IGUISkin* skin = Environment->getSkin();
|
||||
if (!skin)
|
||||
return;
|
||||
irr::video::IVideoDriver* driver = Environment->getVideoDriver();
|
||||
video::IVideoDriver* driver = Environment->getVideoDriver();
|
||||
|
||||
core::rect<s32> frameRect(AbsoluteRect);
|
||||
|
||||
|
|
|
@ -59,8 +59,8 @@ IMesh* CGeometryCreator::createHillPlaneMesh(
|
|||
vtx.TCoords.set(tsx, 1.0f - tsy);
|
||||
|
||||
if (hillHeight != 0.0f)
|
||||
vtx.Pos.Y = (f32)(sin(vtx.Pos.X * countHills.Width * irr::core::PI / center.X) *
|
||||
cos(vtx.Pos.Z * countHills.Height * irr::core::PI / center.Y))
|
||||
vtx.Pos.Y = (f32)(sin(vtx.Pos.X * countHills.Width * core::PI / center.X) *
|
||||
cos(vtx.Pos.Z * countHills.Height * core::PI / center.Y))
|
||||
*hillHeight;
|
||||
|
||||
buffer->Vertices.push_back(vtx);
|
||||
|
|
|
@ -1352,8 +1352,8 @@ void CImage::copyToScalingBoxFilter(IImage* target, s32 bias)
|
|||
|
||||
target->lock();
|
||||
|
||||
s32 fx = irr::core::ceil32 ( sourceXStep );
|
||||
s32 fy = irr::core::ceil32 ( sourceYStep );
|
||||
s32 fx = core::ceil32 ( sourceXStep );
|
||||
s32 fy = core::ceil32 ( sourceYStep );
|
||||
f32 sx;
|
||||
f32 sy;
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ bool CImageLoaderBMP::isALoadableFileExtension(const c8* fileName) const
|
|||
|
||||
|
||||
//! returns true if the file maybe is able to be loaded by this class
|
||||
bool CImageLoaderBMP::isALoadableFileFormat(irr::io::IReadFile* file) const
|
||||
bool CImageLoaderBMP::isALoadableFileFormat(io::IReadFile* file) const
|
||||
{
|
||||
u16 headerID;
|
||||
file->read(&headerID, sizeof(u16));
|
||||
|
@ -213,7 +213,7 @@ void CImageLoaderBMP::decompress4BitRLE(u8*& bmpData, s32 size, s32 width, s32 h
|
|||
|
||||
|
||||
//! creates a surface from the file
|
||||
IImage* CImageLoaderBMP::loadImage(irr::io::IReadFile* file) const
|
||||
IImage* CImageLoaderBMP::loadImage(io::IReadFile* file) const
|
||||
{
|
||||
SBMPHeader header;
|
||||
|
||||
|
|
|
@ -84,10 +84,10 @@ public:
|
|||
virtual bool isALoadableFileExtension(const c8* fileName) const;
|
||||
|
||||
//! returns true if the file maybe is able to be loaded by this class
|
||||
virtual bool isALoadableFileFormat(irr::io::IReadFile* file) const;
|
||||
virtual bool isALoadableFileFormat(io::IReadFile* file) const;
|
||||
|
||||
//! creates a surface from the file
|
||||
virtual IImage* loadImage(irr::io::IReadFile* file) const;
|
||||
virtual IImage* loadImage(io::IReadFile* file) const;
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ void CImageLoaderJPG::output_message(j_common_ptr cinfo)
|
|||
#endif // _IRR_COMPILE_WITH_LIBJPEG_
|
||||
|
||||
//! returns true if the file maybe is able to be loaded by this class
|
||||
bool CImageLoaderJPG::isALoadableFileFormat(irr::io::IReadFile* file) const
|
||||
bool CImageLoaderJPG::isALoadableFileFormat(io::IReadFile* file) const
|
||||
{
|
||||
#ifndef _IRR_COMPILE_WITH_LIBJPEG_
|
||||
return false;
|
||||
|
@ -127,7 +127,7 @@ bool CImageLoaderJPG::isALoadableFileFormat(irr::io::IReadFile* file) const
|
|||
}
|
||||
|
||||
//! creates a surface from the file
|
||||
IImage* CImageLoaderJPG::loadImage(irr::io::IReadFile* file) const
|
||||
IImage* CImageLoaderJPG::loadImage(io::IReadFile* file) const
|
||||
{
|
||||
#ifndef _IRR_COMPILE_WITH_LIBJPEG_
|
||||
return 0;
|
||||
|
|
|
@ -44,10 +44,10 @@ public:
|
|||
virtual bool isALoadableFileExtension(const c8* fileName) const;
|
||||
|
||||
//! returns true if the file maybe is able to be loaded by this class
|
||||
virtual bool isALoadableFileFormat(irr::io::IReadFile* file) const;
|
||||
virtual bool isALoadableFileFormat(io::IReadFile* file) const;
|
||||
|
||||
//! creates a surface from the file
|
||||
virtual IImage* loadImage(irr::io::IReadFile* file) const;
|
||||
virtual IImage* loadImage(io::IReadFile* file) const;
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ bool CImageLoaderPCX::isALoadableFileExtension(const c8* fileName) const
|
|||
|
||||
|
||||
//! returns true if the file maybe is able to be loaded by this class
|
||||
bool CImageLoaderPCX::isALoadableFileFormat(irr::io::IReadFile* file) const
|
||||
bool CImageLoaderPCX::isALoadableFileFormat(io::IReadFile* file) const
|
||||
{
|
||||
u8 headerID;
|
||||
file->read(&headerID, sizeof(headerID));
|
||||
|
@ -45,7 +45,7 @@ bool CImageLoaderPCX::isALoadableFileFormat(irr::io::IReadFile* file) const
|
|||
|
||||
|
||||
//! creates a image from the file
|
||||
IImage* CImageLoaderPCX::loadImage(irr::io::IReadFile* file) const
|
||||
IImage* CImageLoaderPCX::loadImage(io::IReadFile* file) const
|
||||
{
|
||||
SPCXHeader header;
|
||||
s32* paletteData = 0;
|
||||
|
|
|
@ -72,10 +72,10 @@ public:
|
|||
virtual bool isALoadableFileExtension(const c8* fileName) const;
|
||||
|
||||
//! returns true if the file maybe is able to be loaded by this class
|
||||
virtual bool isALoadableFileFormat(irr::io::IReadFile* file) const;
|
||||
virtual bool isALoadableFileFormat(io::IReadFile* file) const;
|
||||
|
||||
//! creates a surface from the file
|
||||
virtual IImage* loadImage(irr::io::IReadFile* file) const;
|
||||
virtual IImage* loadImage(io::IReadFile* file) const;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ bool CImageLoaderPSD::isALoadableFileExtension(const c8* fileName) const
|
|||
|
||||
|
||||
//! returns true if the file maybe is able to be loaded by this class
|
||||
bool CImageLoaderPSD::isALoadableFileFormat(irr::io::IReadFile* file) const
|
||||
bool CImageLoaderPSD::isALoadableFileFormat(io::IReadFile* file) const
|
||||
{
|
||||
if (!file)
|
||||
return false;
|
||||
|
@ -47,7 +47,7 @@ bool CImageLoaderPSD::isALoadableFileFormat(irr::io::IReadFile* file) const
|
|||
|
||||
|
||||
//! creates a surface from the file
|
||||
IImage* CImageLoaderPSD::loadImage(irr::io::IReadFile* file) const
|
||||
IImage* CImageLoaderPSD::loadImage(io::IReadFile* file) const
|
||||
{
|
||||
u32* imageData = 0;
|
||||
|
||||
|
@ -160,7 +160,7 @@ IImage* CImageLoaderPSD::loadImage(irr::io::IReadFile* file) const
|
|||
}
|
||||
|
||||
|
||||
bool CImageLoaderPSD::readRawImageData(irr::io::IReadFile* file, const PsdHeader& header, u32* imageData) const
|
||||
bool CImageLoaderPSD::readRawImageData(io::IReadFile* file, const PsdHeader& header, u32* imageData) const
|
||||
{
|
||||
u8* tmpData = new u8[header.width * header.height];
|
||||
|
||||
|
@ -195,7 +195,7 @@ bool CImageLoaderPSD::readRawImageData(irr::io::IReadFile* file, const PsdHeader
|
|||
}
|
||||
|
||||
|
||||
bool CImageLoaderPSD::readRLEImageData(irr::io::IReadFile* file, const PsdHeader& header, u32* imageData) const
|
||||
bool CImageLoaderPSD::readRLEImageData(io::IReadFile* file, const PsdHeader& header, u32* imageData) const
|
||||
{
|
||||
/* If the compression code is 1, the image data
|
||||
starts with the byte counts for all the scan lines in the channel
|
||||
|
|
|
@ -59,15 +59,15 @@ public:
|
|||
virtual bool isALoadableFileExtension(const c8* fileName) const;
|
||||
|
||||
//! returns true if the file maybe is able to be loaded by this class
|
||||
virtual bool isALoadableFileFormat(irr::io::IReadFile* file) const;
|
||||
virtual bool isALoadableFileFormat(io::IReadFile* file) const;
|
||||
|
||||
//! creates a surface from the file
|
||||
virtual IImage* loadImage(irr::io::IReadFile* file) const;
|
||||
virtual IImage* loadImage(io::IReadFile* file) const;
|
||||
|
||||
private:
|
||||
|
||||
bool readRawImageData(irr::io::IReadFile* file, const PsdHeader& header, u32* imageData) const;
|
||||
bool readRLEImageData(irr::io::IReadFile* file, const PsdHeader& header, u32* imageData) const;
|
||||
bool readRawImageData(io::IReadFile* file, const PsdHeader& header, u32* imageData) const;
|
||||
bool readRLEImageData(io::IReadFile* file, const PsdHeader& header, u32* imageData) const;
|
||||
s16 getShiftFromChannel(c8 channelNr, const PsdHeader& header) const;
|
||||
};
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ bool CImageLoaderTGA::isALoadableFileExtension(const c8* fileName) const
|
|||
|
||||
|
||||
//! loads a compressed tga.
|
||||
u8 *CImageLoaderTGA::loadCompressedImage(irr::io::IReadFile *file, const STGAHeader& header) const
|
||||
u8 *CImageLoaderTGA::loadCompressedImage(io::IReadFile *file, const STGAHeader& header) const
|
||||
{
|
||||
// This was written and sent in by Jon Pry, thank you very much!
|
||||
// I only changed the formatting a little bit.
|
||||
|
@ -75,7 +75,7 @@ u8 *CImageLoaderTGA::loadCompressedImage(irr::io::IReadFile *file, const STGAHea
|
|||
|
||||
|
||||
//! returns true if the file maybe is able to be loaded by this class
|
||||
bool CImageLoaderTGA::isALoadableFileFormat(irr::io::IReadFile* file) const
|
||||
bool CImageLoaderTGA::isALoadableFileFormat(io::IReadFile* file) const
|
||||
{
|
||||
if (!file)
|
||||
return false;
|
||||
|
@ -90,7 +90,7 @@ bool CImageLoaderTGA::isALoadableFileFormat(irr::io::IReadFile* file) const
|
|||
|
||||
|
||||
//! creates a surface from the file
|
||||
IImage* CImageLoaderTGA::loadImage(irr::io::IReadFile* file) const
|
||||
IImage* CImageLoaderTGA::loadImage(io::IReadFile* file) const
|
||||
{
|
||||
STGAHeader header;
|
||||
u8* colorMap = 0;
|
||||
|
|
|
@ -67,15 +67,15 @@ public:
|
|||
virtual bool isALoadableFileExtension(const c8* fileName) const;
|
||||
|
||||
//! returns true if the file maybe is able to be loaded by this class
|
||||
virtual bool isALoadableFileFormat(irr::io::IReadFile* file) const;
|
||||
virtual bool isALoadableFileFormat(io::IReadFile* file) const;
|
||||
|
||||
//! creates a surface from the file
|
||||
virtual IImage* loadImage(irr::io::IReadFile* file) const;
|
||||
virtual IImage* loadImage(io::IReadFile* file) const;
|
||||
|
||||
private:
|
||||
|
||||
//! loads a compressed tga. Was written and sent in by Jon Pry, thank you very much!
|
||||
u8* loadCompressedImage(irr::io::IReadFile *file, const STGAHeader& header) const;
|
||||
u8* loadCompressedImage(io::IReadFile *file, const STGAHeader& header) const;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ void PNGAPI user_write_data_fcn(png_structp png_ptr, png_bytep data, png_size_t
|
|||
{
|
||||
png_size_t check;
|
||||
|
||||
irr::io::IWriteFile* file=(irr::io::IWriteFile*)png_ptr->io_ptr;
|
||||
io::IWriteFile* file=(io::IWriteFile*)png_ptr->io_ptr;
|
||||
check=(png_size_t) file->write((void*)data,length);
|
||||
|
||||
if (check != length)
|
||||
|
|
|
@ -667,7 +667,7 @@ bool CIrrDeviceLinux::run()
|
|||
#ifdef _IRR_COMPILE_WITH_X11_
|
||||
if (DriverType != video::EDT_NULL)
|
||||
{
|
||||
irr::SEvent irrevent;
|
||||
SEvent irrevent;
|
||||
|
||||
while (XPending(display) > 0 && !Close)
|
||||
{
|
||||
|
|
|
@ -201,7 +201,7 @@ bool CIrrDeviceSDL::run()
|
|||
{
|
||||
os::Timer::tick();
|
||||
|
||||
irr::SEvent irrevent;
|
||||
SEvent irrevent;
|
||||
|
||||
while ( !Close && SDL_PollEvent( &SDL_event ) )
|
||||
{
|
||||
|
|
|
@ -17,12 +17,12 @@ namespace irr
|
|||
{
|
||||
|
||||
//! constructor
|
||||
CIrrDeviceStub::CIrrDeviceStub(const char* version, irr::IEventReceiver* recv)
|
||||
CIrrDeviceStub::CIrrDeviceStub(const char* version, IEventReceiver* recv)
|
||||
: IrrlichtDevice(), VideoDriver(0), GUIEnvironment(0), SceneManager(0),
|
||||
Timer(0), CursorControl(0), UserReceiver(recv), Logger(0), Operator(0),
|
||||
FileSystem(io::createFileSystem()), InputReceivingSceneManager(0)
|
||||
{
|
||||
Timer = new irr::CTimer();
|
||||
Timer = new CTimer();
|
||||
Logger = new CLogger(UserReceiver);
|
||||
os::Printer::Logger = Logger;
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace irr
|
|||
public:
|
||||
|
||||
//! constructor
|
||||
CIrrDeviceStub(const char* version, irr::IEventReceiver* resv);
|
||||
CIrrDeviceStub(const char* version, IEventReceiver* resv);
|
||||
|
||||
//! destructor
|
||||
virtual ~CIrrDeviceStub();
|
||||
|
|
|
@ -48,7 +48,7 @@ bool CIrrMeshFileLoader::isALoadableFileExtension(const c8* fileName) const
|
|||
//! \return Pointer to the created mesh. Returns 0 if loading failed.
|
||||
//! If you no longer need the mesh, you should call IAnimatedMesh::drop().
|
||||
//! See IReferenceCounted::drop() for more information.
|
||||
IAnimatedMesh* CIrrMeshFileLoader::createMesh(irr::io::IReadFile* file)
|
||||
IAnimatedMesh* CIrrMeshFileLoader::createMesh(io::IReadFile* file)
|
||||
{
|
||||
io::IXMLReader* reader = FileSystem->createXMLReader(file);
|
||||
if (!reader)
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
//! \return Pointer to the created mesh. Returns 0 if loading failed.
|
||||
//! If you no longer need the mesh, you should call IAnimatedMesh::drop().
|
||||
//! See IReferenceCounted::drop() for more information.
|
||||
virtual IAnimatedMesh* createMesh(irr::io::IReadFile* file);
|
||||
virtual IAnimatedMesh* createMesh(io::IReadFile* file);
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "CIrrMeshWriter.h"
|
||||
#include "os.h"
|
||||
#include "IWriteFile.h"
|
||||
#include "IXMLWriter.h"
|
||||
#include "IMesh.h"
|
||||
#include "IAttributes.h"
|
||||
|
@ -10,8 +11,8 @@ namespace scene
|
|||
{
|
||||
|
||||
|
||||
CIrrMeshWriter::CIrrMeshWriter(irr::video::IVideoDriver* driver,
|
||||
irr::io::IFileSystem* fs)
|
||||
CIrrMeshWriter::CIrrMeshWriter(video::IVideoDriver* driver,
|
||||
io::IFileSystem* fs)
|
||||
: FileSystem(fs), VideoDriver(driver), Writer(0)
|
||||
{
|
||||
if (VideoDriver)
|
||||
|
@ -83,7 +84,7 @@ bool CIrrMeshWriter::writeMesh(io::IWriteFile* file, scene::IMesh* mesh, s32 fla
|
|||
|
||||
for (int i=0; i<(int)mesh->getMeshBufferCount(); ++i)
|
||||
{
|
||||
irr::scene::IMeshBuffer* buffer = mesh->getMeshBuffer(i);
|
||||
scene::IMeshBuffer* buffer = mesh->getMeshBuffer(i);
|
||||
if (buffer)
|
||||
{
|
||||
writeMeshBuffer(buffer);
|
||||
|
@ -272,7 +273,7 @@ void CIrrMeshWriter::writeMaterial(const video::SMaterial& material)
|
|||
{
|
||||
// simply use irrlichts built-in attribute serialization capabilities here:
|
||||
|
||||
irr::io::IAttributes* attributes =
|
||||
io::IAttributes* attributes =
|
||||
VideoDriver->createAttributesFromMaterial(material);
|
||||
|
||||
if (attributes)
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace scene
|
|||
{
|
||||
public:
|
||||
|
||||
CIrrMeshWriter(irr::video::IVideoDriver* driver, irr::io::IFileSystem* fs);
|
||||
CIrrMeshWriter(video::IVideoDriver* driver, io::IFileSystem* fs);
|
||||
virtual ~CIrrMeshWriter();
|
||||
|
||||
//! Returns the type of the mesh writer
|
||||
|
|
|
@ -126,7 +126,7 @@ bool CLMTSMeshFileLoader::isALoadableFileExtension(const c8* filename) const
|
|||
}
|
||||
|
||||
|
||||
IAnimatedMesh* CLMTSMeshFileLoader::createMesh(irr::io::IReadFile* file)
|
||||
IAnimatedMesh* CLMTSMeshFileLoader::createMesh(io::IReadFile* file)
|
||||
{
|
||||
u32 i;
|
||||
u32 id;
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
|
||||
virtual bool isALoadableFileExtension(const c8* fileName) const;
|
||||
|
||||
virtual IAnimatedMesh* createMesh(irr::io::IReadFile* file);
|
||||
virtual IAnimatedMesh* createMesh(io::IReadFile* file);
|
||||
|
||||
private:
|
||||
void constructMesh(SMesh* mesh);
|
||||
|
|
|
@ -31,7 +31,7 @@ bool CMD2MeshFileLoader::isALoadableFileExtension(const c8* filename) const
|
|||
//! \return Pointer to the created mesh. Returns 0 if loading failed.
|
||||
//! If you no longer need the mesh, you should call IAnimatedMesh::drop().
|
||||
//! See IReferenceCounted::drop() for more information.
|
||||
IAnimatedMesh* CMD2MeshFileLoader::createMesh(irr::io::IReadFile* file)
|
||||
IAnimatedMesh* CMD2MeshFileLoader::createMesh(io::IReadFile* file)
|
||||
{
|
||||
IAnimatedMesh* msh = new CAnimatedMeshMD2();
|
||||
if (msh)
|
||||
|
|
|
@ -28,7 +28,7 @@ public:
|
|||
//! \return Pointer to the created mesh. Returns 0 if loading failed.
|
||||
//! If you no longer need the mesh, you should call IAnimatedMesh::drop().
|
||||
//! See IReferenceCounted::drop() for more information.
|
||||
virtual IAnimatedMesh* createMesh(irr::io::IReadFile* file);
|
||||
virtual IAnimatedMesh* createMesh(io::IReadFile* file);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ bool CMD3MeshFileLoader::isALoadableFileExtension(const c8* filename) const
|
|||
}
|
||||
|
||||
|
||||
IAnimatedMesh* CMD3MeshFileLoader::createMesh(irr::io::IReadFile* file)
|
||||
IAnimatedMesh* CMD3MeshFileLoader::createMesh(io::IReadFile* file)
|
||||
{
|
||||
CAnimatedMeshMD3 * mesh = new CAnimatedMeshMD3();
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ public:
|
|||
//! \return Pointer to the created mesh. Returns 0 if loading failed.
|
||||
//! If you no longer need the mesh, you should call IAnimatedMesh::drop().
|
||||
//! See IReferenceCounted::drop() for more information.
|
||||
virtual IAnimatedMesh* createMesh(irr::io::IReadFile* file);
|
||||
virtual IAnimatedMesh* createMesh(io::IReadFile* file);
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ bool CMS3DMeshFileLoader::isALoadableFileExtension(const c8* filename) const
|
|||
//! \return Pointer to the created mesh. Returns 0 if loading failed.
|
||||
//! If you no longer need the mesh, you should call IAnimatedMesh::drop().
|
||||
//! See IReferenceCounted::drop() for more information.
|
||||
IAnimatedMesh* CMS3DMeshFileLoader::createMesh(irr::io::IReadFile* file)
|
||||
IAnimatedMesh* CMS3DMeshFileLoader::createMesh(io::IReadFile* file)
|
||||
{
|
||||
if (!file)
|
||||
return 0;
|
||||
|
|
|
@ -30,13 +30,13 @@ public:
|
|||
//! \return Pointer to the created mesh. Returns 0 if loading failed.
|
||||
//! If you no longer need the mesh, you should call IAnimatedMesh::drop().
|
||||
//! See IReferenceCounted::drop() for more information.
|
||||
virtual IAnimatedMesh* createMesh(irr::io::IReadFile* file);
|
||||
virtual IAnimatedMesh* createMesh(io::IReadFile* file);
|
||||
|
||||
private:
|
||||
|
||||
core::stringc stripPathFromString(core::stringc string, bool returnPath);
|
||||
|
||||
bool load(irr::io::IReadFile* file);
|
||||
bool load(io::IReadFile* file);
|
||||
video::IVideoDriver* Driver;
|
||||
CSkinnedMesh* AnimatedMesh;
|
||||
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
#ifdef _IRR_COMPILE_WITH_OBJ_LOADER_
|
||||
|
||||
#include "COBJMeshFileLoader.h"
|
||||
#include "SMesh.h"
|
||||
#include "SMeshBuffer.h"
|
||||
#include "SAnimatedMesh.h"
|
||||
#include "IReadFile.h"
|
||||
#include "fast_atof.h"
|
||||
#include "irrString.h"
|
||||
#include "coreutil.h"
|
||||
|
||||
namespace irr
|
||||
|
@ -20,7 +20,7 @@ namespace scene
|
|||
|
||||
//! Constructor
|
||||
COBJMeshFileLoader::COBJMeshFileLoader(io::IFileSystem* fs, video::IVideoDriver* driver)
|
||||
: FileSystem(fs), Driver(driver), Mesh(0)
|
||||
: FileSystem(fs), Driver(driver)
|
||||
{
|
||||
if (FileSystem)
|
||||
FileSystem->grab();
|
||||
|
@ -39,9 +39,6 @@ COBJMeshFileLoader::~COBJMeshFileLoader()
|
|||
|
||||
if (Driver)
|
||||
Driver->drop();
|
||||
|
||||
if (Mesh)
|
||||
Mesh->drop();
|
||||
}
|
||||
|
||||
|
||||
|
@ -67,16 +64,14 @@ IAnimatedMesh* COBJMeshFileLoader::createMesh(io::IReadFile* file)
|
|||
|
||||
const u32 WORD_BUFFER_LENGTH = 512;
|
||||
|
||||
if (Mesh)
|
||||
Mesh->drop();
|
||||
Mesh = new SMesh();
|
||||
SMesh* mesh = new SMesh();
|
||||
|
||||
core::array<core::vector3df> vertexBuffer;
|
||||
core::array<core::vector2df> textureCoordBuffer;
|
||||
core::array<core::vector3df> normalsBuffer;
|
||||
SObjMtl * pCurrMtl = new SObjMtl();
|
||||
pCurrMtl->name="";
|
||||
materials.push_back(pCurrMtl);
|
||||
SObjMtl * currMtl = new SObjMtl();
|
||||
currMtl->name="";
|
||||
materials.push_back(currMtl);
|
||||
u32 smoothingGroup=0;
|
||||
|
||||
// ********************************************************************
|
||||
|
@ -104,26 +99,26 @@ IAnimatedMesh* COBJMeshFileLoader::createMesh(io::IReadFile* file)
|
|||
const c8* const pBufEnd = pBuf+filesize;
|
||||
|
||||
// Process obj information
|
||||
const c8* pBufPtr = pBuf;
|
||||
while(pBufPtr != pBufEnd)
|
||||
const c8* bufPtr = pBuf;
|
||||
while(bufPtr != pBufEnd)
|
||||
{
|
||||
switch(pBufPtr[0])
|
||||
switch(bufPtr[0])
|
||||
{
|
||||
case 'm': // mtllib (material)
|
||||
{
|
||||
c8 name[WORD_BUFFER_LENGTH];
|
||||
pBufPtr = goAndCopyNextWord(name, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
bufPtr = goAndCopyNextWord(name, bufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
readMTL(name, obj_relpath);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'v': // v, vn, vt
|
||||
switch(pBufPtr[1])
|
||||
switch(bufPtr[1])
|
||||
{
|
||||
case ' ': // vertex
|
||||
{
|
||||
core::vector3df vec;
|
||||
pBufPtr = readVec3(pBufPtr, vec, pBufEnd);
|
||||
bufPtr = readVec3(bufPtr, vec, pBufEnd);
|
||||
vertexBuffer.push_back(vec);
|
||||
}
|
||||
break;
|
||||
|
@ -131,7 +126,7 @@ IAnimatedMesh* COBJMeshFileLoader::createMesh(io::IReadFile* file)
|
|||
case 'n': // normal
|
||||
{
|
||||
core::vector3df vec;
|
||||
pBufPtr = readVec3(pBufPtr, vec, pBufEnd);
|
||||
bufPtr = readVec3(bufPtr, vec, pBufEnd);
|
||||
normalsBuffer.push_back(vec);
|
||||
}
|
||||
break;
|
||||
|
@ -139,7 +134,7 @@ IAnimatedMesh* COBJMeshFileLoader::createMesh(io::IReadFile* file)
|
|||
case 't': // texcoord
|
||||
{
|
||||
core::vector2df vec;
|
||||
pBufPtr = readVec2(pBufPtr, vec, pBufEnd);
|
||||
bufPtr = readVec2(bufPtr, vec, pBufEnd);
|
||||
textureCoordBuffer.push_back(vec);
|
||||
}
|
||||
break;
|
||||
|
@ -154,7 +149,7 @@ IAnimatedMesh* COBJMeshFileLoader::createMesh(io::IReadFile* file)
|
|||
case 's': // smoothing can be a group or off (equiv. to 0)
|
||||
{
|
||||
c8 smooth[WORD_BUFFER_LENGTH];
|
||||
pBufPtr = goAndCopyNextWord(smooth, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
bufPtr = goAndCopyNextWord(smooth, bufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
if (core::stringc("off")==smooth)
|
||||
smoothingGroup=0;
|
||||
else
|
||||
|
@ -166,12 +161,12 @@ IAnimatedMesh* COBJMeshFileLoader::createMesh(io::IReadFile* file)
|
|||
// get name of material
|
||||
{
|
||||
c8 matName[WORD_BUFFER_LENGTH];
|
||||
pBufPtr = goAndCopyNextWord(matName, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
bufPtr = goAndCopyNextWord(matName, bufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
// retrieve the material
|
||||
SObjMtl *pUseMtl = findMtl(matName);
|
||||
// only change material if we found it
|
||||
if (pUseMtl)
|
||||
pCurrMtl = pUseMtl;
|
||||
currMtl = pUseMtl;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -179,21 +174,21 @@ IAnimatedMesh* COBJMeshFileLoader::createMesh(io::IReadFile* file)
|
|||
{
|
||||
c8 vertexWord[WORD_BUFFER_LENGTH]; // for retrieving vertex data
|
||||
video::S3DVertex v;
|
||||
u32 currentVertexCount = pCurrMtl->pMeshbuffer->Vertices.size();
|
||||
u32 currentVertexCount = currMtl->Meshbuffer->Vertices.size();
|
||||
u32 facePointCount = 0; // number of vertices in this face
|
||||
|
||||
// Assign vertex color from currently active material's diffuse colour
|
||||
if (pCurrMtl)
|
||||
v.Color = pCurrMtl->pMeshbuffer->Material.DiffuseColor;
|
||||
if (currMtl)
|
||||
v.Color = currMtl->Meshbuffer->Material.DiffuseColor;
|
||||
|
||||
// get all vertices data in this face (current line of obj file)
|
||||
const core::stringc wordBuffer = copyLine(pBufPtr, pBufEnd);
|
||||
const c8* pLinePtr = wordBuffer.c_str();
|
||||
const c8* const pEndPtr = pLinePtr+wordBuffer.size();
|
||||
const core::stringc wordBuffer = copyLine(bufPtr, pBufEnd);
|
||||
const c8* linePtr = wordBuffer.c_str();
|
||||
const c8* const endPtr = linePtr+wordBuffer.size();
|
||||
|
||||
// read in all vertices
|
||||
pLinePtr = goNextWord(pLinePtr, pEndPtr);
|
||||
while (0 != pLinePtr[0])
|
||||
linePtr = goNextWord(linePtr, endPtr);
|
||||
while (0 != linePtr[0])
|
||||
{
|
||||
// Array to communicate with retrieveVertexIndices()
|
||||
// sends the buffer sizes and gets the actual indices
|
||||
|
@ -202,7 +197,7 @@ IAnimatedMesh* COBJMeshFileLoader::createMesh(io::IReadFile* file)
|
|||
Idx[1] = Idx[2] = -1;
|
||||
|
||||
// read in next vertex's data
|
||||
u32 wlength = copyWord(vertexWord, pLinePtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
u32 wlength = copyWord(vertexWord, linePtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
// this function will also convert obj's 1-based index to c++'s 0-based index
|
||||
retrieveVertexIndices(vertexWord, Idx, vertexWord+wlength+1, vertexBuffer.size(), textureCoordBuffer.size(), normalsBuffer.size());
|
||||
v.Pos = vertexBuffer[Idx[0]];
|
||||
|
@ -214,23 +209,23 @@ IAnimatedMesh* COBJMeshFileLoader::createMesh(io::IReadFile* file)
|
|||
v.Normal = normalsBuffer[Idx[2]];
|
||||
else
|
||||
v.Normal.set(0.0f,0.0f,0.0f);
|
||||
pCurrMtl->pMeshbuffer->Vertices.push_back(v);
|
||||
currMtl->Meshbuffer->Vertices.push_back(v);
|
||||
++facePointCount;
|
||||
|
||||
// go to next vertex
|
||||
pLinePtr = goNextWord(pLinePtr, pEndPtr);
|
||||
linePtr = goNextWord(linePtr, endPtr);
|
||||
}
|
||||
|
||||
// Add indices for first 3 vertices
|
||||
pCurrMtl->pMeshbuffer->Indices.push_back( currentVertexCount );
|
||||
pCurrMtl->pMeshbuffer->Indices.push_back( ( facePointCount - 1 ) + currentVertexCount );
|
||||
pCurrMtl->pMeshbuffer->Indices.push_back( ( facePointCount - 2 ) + currentVertexCount );
|
||||
currMtl->Meshbuffer->Indices.push_back( currentVertexCount );
|
||||
currMtl->Meshbuffer->Indices.push_back( ( facePointCount - 1 ) + currentVertexCount );
|
||||
currMtl->Meshbuffer->Indices.push_back( ( facePointCount - 2 ) + currentVertexCount );
|
||||
// Add indices for subsequent vertices
|
||||
for ( u32 i = 0; i < facePointCount - 3; ++i )
|
||||
{
|
||||
pCurrMtl->pMeshbuffer->Indices.push_back( currentVertexCount );
|
||||
pCurrMtl->pMeshbuffer->Indices.push_back( ( facePointCount - 2 - i ) + currentVertexCount );
|
||||
pCurrMtl->pMeshbuffer->Indices.push_back( ( facePointCount - 3 - i ) + currentVertexCount );
|
||||
currMtl->Meshbuffer->Indices.push_back( currentVertexCount );
|
||||
currMtl->Meshbuffer->Indices.push_back( ( facePointCount - 2 - i ) + currentVertexCount );
|
||||
currMtl->Meshbuffer->Indices.push_back( ( facePointCount - 3 - i ) + currentVertexCount );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -238,29 +233,29 @@ IAnimatedMesh* COBJMeshFileLoader::createMesh(io::IReadFile* file)
|
|||
case '#': // comment
|
||||
default:
|
||||
break;
|
||||
} // end switch(pBufPtr[0])
|
||||
} // end switch(bufPtr[0])
|
||||
// eat up rest of line
|
||||
pBufPtr = goNextLine(pBufPtr, pBufEnd);
|
||||
} // end while(pBufPtr && (pBufPtr-pBuf<filesize))
|
||||
bufPtr = goNextLine(bufPtr, pBufEnd);
|
||||
} // end while(bufPtr && (bufPtr-pBuf<filesize))
|
||||
|
||||
// Combine all the groups (meshbuffers) into the mesh
|
||||
for ( u32 m = 0; m < materials.size(); ++m )
|
||||
{
|
||||
if ( materials[m]->pMeshbuffer->getIndexCount() > 0 )
|
||||
if ( materials[m]->Meshbuffer->getIndexCount() > 0 )
|
||||
{
|
||||
materials[m]->pMeshbuffer->recalculateBoundingBox();
|
||||
Mesh->addMeshBuffer( materials[m]->pMeshbuffer );
|
||||
materials[m]->Meshbuffer->recalculateBoundingBox();
|
||||
mesh->addMeshBuffer( materials[m]->Meshbuffer );
|
||||
}
|
||||
}
|
||||
|
||||
// Create the Animated mesh if there's anything in the mesh
|
||||
SAnimatedMesh* pAM = 0;
|
||||
if ( 0 != Mesh->getMeshBufferCount() )
|
||||
if ( 0 != mesh->getMeshBufferCount() )
|
||||
{
|
||||
Mesh->recalculateBoundingBox();
|
||||
mesh->recalculateBoundingBox();
|
||||
pAM = new SAnimatedMesh();
|
||||
pAM->Type = EAMT_OBJ;
|
||||
pAM->addMesh(Mesh);
|
||||
pAM->addMesh(mesh);
|
||||
pAM->recalculateBoundingBox();
|
||||
}
|
||||
|
||||
|
@ -268,8 +263,7 @@ IAnimatedMesh* COBJMeshFileLoader::createMesh(io::IReadFile* file)
|
|||
delete [] pBuf;
|
||||
// more cleaning up
|
||||
cleanUp();
|
||||
Mesh->drop();
|
||||
Mesh = 0;
|
||||
mesh->drop();
|
||||
|
||||
return pAM;
|
||||
}
|
||||
|
@ -298,10 +292,10 @@ void COBJMeshFileLoader::readMTL(const c8* pFileName, core::stringc relPath)
|
|||
|
||||
SObjMtl* pCurrMaterial = 0;
|
||||
|
||||
const c8* pBufPtr = pBuf;
|
||||
while(pBufPtr != pBufEnd)
|
||||
const c8* bufPtr = pBuf;
|
||||
while(bufPtr != pBufEnd)
|
||||
{
|
||||
switch(*pBufPtr)
|
||||
switch(*bufPtr)
|
||||
{
|
||||
case 'n': // newmtl
|
||||
{
|
||||
|
@ -311,7 +305,7 @@ void COBJMeshFileLoader::readMTL(const c8* pFileName, core::stringc relPath)
|
|||
|
||||
// extract new material's name
|
||||
c8 mtlNameBuf[WORD_BUFFER_LENGTH];
|
||||
pBufPtr = goAndCopyNextWord(mtlNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
bufPtr = goAndCopyNextWord(mtlNameBuf, bufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
|
||||
pCurrMaterial = new SObjMtl;
|
||||
pCurrMaterial->name = mtlNameBuf;
|
||||
|
@ -323,7 +317,7 @@ void COBJMeshFileLoader::readMTL(const c8* pFileName, core::stringc relPath)
|
|||
const u32 COLOR_BUFFER_LENGTH = 16;
|
||||
c8 illumStr[COLOR_BUFFER_LENGTH];
|
||||
|
||||
pBufPtr = goAndCopyNextWord(illumStr, pBufPtr, COLOR_BUFFER_LENGTH, pBufEnd);
|
||||
bufPtr = goAndCopyNextWord(illumStr, bufPtr, COLOR_BUFFER_LENGTH, pBufEnd);
|
||||
pCurrMaterial->illumination = (c8)atol(illumStr);
|
||||
}
|
||||
break;
|
||||
|
@ -333,116 +327,116 @@ void COBJMeshFileLoader::readMTL(const c8* pFileName, core::stringc relPath)
|
|||
const u32 COLOR_BUFFER_LENGTH = 16;
|
||||
c8 nsStr[COLOR_BUFFER_LENGTH];
|
||||
|
||||
pBufPtr = goAndCopyNextWord(nsStr, pBufPtr, COLOR_BUFFER_LENGTH, pBufEnd);
|
||||
bufPtr = goAndCopyNextWord(nsStr, bufPtr, COLOR_BUFFER_LENGTH, pBufEnd);
|
||||
f32 shininessValue = core::fast_atof(nsStr);
|
||||
|
||||
// wavefront shininess is from [0, 1000], so scale for OpenGL
|
||||
shininessValue *= 0.128f;
|
||||
pCurrMaterial->pMeshbuffer->Material.Shininess = shininessValue;
|
||||
pCurrMaterial->Meshbuffer->Material.Shininess = shininessValue;
|
||||
}
|
||||
break;
|
||||
case 'K':
|
||||
if ( pCurrMaterial )
|
||||
{
|
||||
switch(pBufPtr[1])
|
||||
switch(bufPtr[1])
|
||||
{
|
||||
case 'd': // Kd = diffuse
|
||||
{
|
||||
pBufPtr = readColor(pBufPtr, pCurrMaterial->pMeshbuffer->Material.DiffuseColor, pBufEnd);
|
||||
bufPtr = readColor(bufPtr, pCurrMaterial->Meshbuffer->Material.DiffuseColor, pBufEnd);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case 's': // Ks = specular
|
||||
{
|
||||
pBufPtr = readColor(pBufPtr, pCurrMaterial->pMeshbuffer->Material.SpecularColor, pBufEnd);
|
||||
bufPtr = readColor(bufPtr, pCurrMaterial->Meshbuffer->Material.SpecularColor, pBufEnd);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'a': // Ka = ambience
|
||||
{
|
||||
pBufPtr=readColor(pBufPtr, pCurrMaterial->pMeshbuffer->Material.AmbientColor, pBufEnd);
|
||||
bufPtr=readColor(bufPtr, pCurrMaterial->Meshbuffer->Material.AmbientColor, pBufEnd);
|
||||
}
|
||||
break;
|
||||
case 'e': // Ke = emissive
|
||||
{
|
||||
pBufPtr=readColor(pBufPtr, pCurrMaterial->pMeshbuffer->Material.EmissiveColor, pBufEnd);
|
||||
bufPtr=readColor(bufPtr, pCurrMaterial->Meshbuffer->Material.EmissiveColor, pBufEnd);
|
||||
}
|
||||
break;
|
||||
} // end switch(pBufPtr[1])
|
||||
} // end switch(bufPtr[1])
|
||||
} // end case 'K': if ( 0 != pCurrMaterial )...
|
||||
break;
|
||||
case 'm': // texture maps
|
||||
if (pCurrMaterial)
|
||||
{
|
||||
u8 type=0; // map_Kd - diffuse texture map
|
||||
if (!strncmp(pBufPtr,"map_bump",8))
|
||||
if (!strncmp(bufPtr,"map_bump",8))
|
||||
type=1;
|
||||
else if (!strncmp(pBufPtr,"map_d",5))
|
||||
else if (!strncmp(bufPtr,"map_d",5))
|
||||
type=2;
|
||||
else if (!strncmp(pBufPtr,"map_refl",8))
|
||||
else if (!strncmp(bufPtr,"map_refl",8))
|
||||
type=3;
|
||||
// extract new material's name
|
||||
c8 textureNameBuf[WORD_BUFFER_LENGTH];
|
||||
pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
bufPtr = goAndCopyNextWord(textureNameBuf, bufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
// handle options
|
||||
while (textureNameBuf[0]=='-')
|
||||
{
|
||||
if (!strncmp(pBufPtr,"-blendu",7))
|
||||
pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
if (!strncmp(pBufPtr,"-blendv",7))
|
||||
pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
if (!strncmp(pBufPtr,"-cc",3))
|
||||
pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
if (!strncmp(pBufPtr,"-clamp",6))
|
||||
pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
if (!strncmp(pBufPtr,"-texres",7))
|
||||
pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
if (!strncmp(pBufPtr,"-mm",3))
|
||||
if (!strncmp(bufPtr,"-blendu",7))
|
||||
bufPtr = goAndCopyNextWord(textureNameBuf, bufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
if (!strncmp(bufPtr,"-blendv",7))
|
||||
bufPtr = goAndCopyNextWord(textureNameBuf, bufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
if (!strncmp(bufPtr,"-cc",3))
|
||||
bufPtr = goAndCopyNextWord(textureNameBuf, bufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
if (!strncmp(bufPtr,"-clamp",6))
|
||||
bufPtr = goAndCopyNextWord(textureNameBuf, bufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
if (!strncmp(bufPtr,"-texres",7))
|
||||
bufPtr = goAndCopyNextWord(textureNameBuf, bufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
if (!strncmp(bufPtr,"-mm",3))
|
||||
{
|
||||
pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
bufPtr = goAndCopyNextWord(textureNameBuf, bufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
bufPtr = goAndCopyNextWord(textureNameBuf, bufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
}
|
||||
if (!strncmp(pBufPtr,"-o",2))
|
||||
if (!strncmp(bufPtr,"-o",2))
|
||||
{
|
||||
pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
bufPtr = goAndCopyNextWord(textureNameBuf, bufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
// next parameters are optional, so skip rest of loop if no number is found
|
||||
pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
bufPtr = goAndCopyNextWord(textureNameBuf, bufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
if (!core::isdigit(textureNameBuf[0]))
|
||||
continue;
|
||||
pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
bufPtr = goAndCopyNextWord(textureNameBuf, bufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
if (!core::isdigit(textureNameBuf[0]))
|
||||
continue;
|
||||
}
|
||||
if (!strncmp(pBufPtr,"-s",2))
|
||||
if (!strncmp(bufPtr,"-s",2))
|
||||
{
|
||||
pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
bufPtr = goAndCopyNextWord(textureNameBuf, bufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
// next parameters are optional, so skip rest of loop if no number is found
|
||||
pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
bufPtr = goAndCopyNextWord(textureNameBuf, bufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
if (!core::isdigit(textureNameBuf[0]))
|
||||
continue;
|
||||
pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
bufPtr = goAndCopyNextWord(textureNameBuf, bufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
if (!core::isdigit(textureNameBuf[0]))
|
||||
continue;
|
||||
}
|
||||
if (!strncmp(pBufPtr,"-t",2))
|
||||
if (!strncmp(bufPtr,"-t",2))
|
||||
{
|
||||
pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
bufPtr = goAndCopyNextWord(textureNameBuf, bufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
// next parameters are optional, so skip rest of loop if no number is found
|
||||
pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
bufPtr = goAndCopyNextWord(textureNameBuf, bufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
if (!core::isdigit(textureNameBuf[0]))
|
||||
continue;
|
||||
pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
bufPtr = goAndCopyNextWord(textureNameBuf, bufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
if (!core::isdigit(textureNameBuf[0]))
|
||||
continue;
|
||||
}
|
||||
// get next word
|
||||
pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
bufPtr = goAndCopyNextWord(textureNameBuf, bufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
}
|
||||
if (type==1)
|
||||
{
|
||||
pCurrMaterial->pMeshbuffer->Material.MaterialTypeParam=core::fast_atof(textureNameBuf);
|
||||
pBufPtr = goAndCopyNextWord(textureNameBuf, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
pCurrMaterial->Meshbuffer->Material.MaterialTypeParam=core::fast_atof(textureNameBuf);
|
||||
bufPtr = goAndCopyNextWord(textureNameBuf, bufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
}
|
||||
|
||||
video::ITexture * pTexture;
|
||||
|
@ -454,28 +448,28 @@ void COBJMeshFileLoader::readMTL(const c8* pFileName, core::stringc relPath)
|
|||
if ( pTexture )
|
||||
{
|
||||
if (type==0)
|
||||
pCurrMaterial->pMeshbuffer->Material.Textures[0] = pTexture;
|
||||
pCurrMaterial->Meshbuffer->Material.Textures[0] = pTexture;
|
||||
else if (type==1)
|
||||
{
|
||||
Driver->makeNormalMapTexture(pTexture);
|
||||
pCurrMaterial->pMeshbuffer->Material.Textures[1] = pTexture;
|
||||
pCurrMaterial->pMeshbuffer->Material.MaterialType=video::EMT_PARALLAX_MAP_SOLID;
|
||||
pCurrMaterial->Meshbuffer->Material.Textures[1] = pTexture;
|
||||
pCurrMaterial->Meshbuffer->Material.MaterialType=video::EMT_PARALLAX_MAP_SOLID;
|
||||
}
|
||||
else if (type==2)
|
||||
{
|
||||
pCurrMaterial->pMeshbuffer->Material.Textures[0] = pTexture;
|
||||
pCurrMaterial->pMeshbuffer->Material.MaterialType=video::EMT_TRANSPARENT_ADD_COLOR;
|
||||
pCurrMaterial->Meshbuffer->Material.Textures[0] = pTexture;
|
||||
pCurrMaterial->Meshbuffer->Material.MaterialType=video::EMT_TRANSPARENT_ADD_COLOR;
|
||||
}
|
||||
else if (type==3)
|
||||
{
|
||||
// pCurrMaterial->pMeshbuffer->Material.Textures[1] = pTexture;
|
||||
// pCurrMaterial->pMeshbuffer->Material.MaterialType=video::EMT_REFLECTION_2_LAYER;
|
||||
// pCurrMaterial->Meshbuffer->Material.Textures[1] = pTexture;
|
||||
// pCurrMaterial->Meshbuffer->Material.MaterialType=video::EMT_REFLECTION_2_LAYER;
|
||||
}
|
||||
// Set diffuse material colour to white so as not to affect texture colour
|
||||
// Because Maya set diffuse colour Kd to black when you use a diffuse colour map
|
||||
// But is this the right thing to do?
|
||||
pCurrMaterial->pMeshbuffer->Material.DiffuseColor.set(
|
||||
pCurrMaterial->pMeshbuffer->Material.DiffuseColor.getAlpha(), 255, 255, 255 );
|
||||
pCurrMaterial->Meshbuffer->Material.DiffuseColor.set(
|
||||
pCurrMaterial->Meshbuffer->Material.DiffuseColor.getAlpha(), 255, 255, 255 );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -485,18 +479,18 @@ void COBJMeshFileLoader::readMTL(const c8* pFileName, core::stringc relPath)
|
|||
const u32 COLOR_BUFFER_LENGTH = 16;
|
||||
c8 dStr[COLOR_BUFFER_LENGTH];
|
||||
|
||||
pBufPtr = goAndCopyNextWord(dStr, pBufPtr, COLOR_BUFFER_LENGTH, pBufEnd);
|
||||
bufPtr = goAndCopyNextWord(dStr, bufPtr, COLOR_BUFFER_LENGTH, pBufEnd);
|
||||
f32 dValue = core::fast_atof(dStr);
|
||||
|
||||
pCurrMaterial->pMeshbuffer->Material.DiffuseColor.setAlpha( (s32)(dValue * 255) );
|
||||
pCurrMaterial->Meshbuffer->Material.DiffuseColor.setAlpha( (s32)(dValue * 255) );
|
||||
if (dValue<1.0f)
|
||||
pCurrMaterial->pMeshbuffer->Material.MaterialType = irr::video::EMT_TRANSPARENT_VERTEX_ALPHA;
|
||||
pCurrMaterial->Meshbuffer->Material.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA;
|
||||
}
|
||||
break;
|
||||
case 'T':
|
||||
if ( pCurrMaterial )
|
||||
{
|
||||
switch ( pBufPtr[1] )
|
||||
switch ( bufPtr[1] )
|
||||
{
|
||||
case 'f': // Tf - Transmitivity
|
||||
const u32 COLOR_BUFFER_LENGTH = 16;
|
||||
|
@ -504,24 +498,24 @@ void COBJMeshFileLoader::readMTL(const c8* pFileName, core::stringc relPath)
|
|||
c8 greenStr[COLOR_BUFFER_LENGTH];
|
||||
c8 blueStr[COLOR_BUFFER_LENGTH];
|
||||
|
||||
pBufPtr = goAndCopyNextWord(redStr, pBufPtr, COLOR_BUFFER_LENGTH, pBufEnd);
|
||||
pBufPtr = goAndCopyNextWord(greenStr, pBufPtr, COLOR_BUFFER_LENGTH, pBufEnd);
|
||||
pBufPtr = goAndCopyNextWord(blueStr, pBufPtr, COLOR_BUFFER_LENGTH, pBufEnd);
|
||||
bufPtr = goAndCopyNextWord(redStr, bufPtr, COLOR_BUFFER_LENGTH, pBufEnd);
|
||||
bufPtr = goAndCopyNextWord(greenStr, bufPtr, COLOR_BUFFER_LENGTH, pBufEnd);
|
||||
bufPtr = goAndCopyNextWord(blueStr, bufPtr, COLOR_BUFFER_LENGTH, pBufEnd);
|
||||
|
||||
f32 transparency = ( core::fast_atof(redStr) + core::fast_atof(greenStr) + core::fast_atof(blueStr) ) / 3;
|
||||
|
||||
pCurrMaterial->pMeshbuffer->Material.DiffuseColor.setAlpha( (s32)(transparency * 255) );
|
||||
pCurrMaterial->Meshbuffer->Material.DiffuseColor.setAlpha( (s32)(transparency * 255) );
|
||||
if (transparency < 1.0f)
|
||||
pCurrMaterial->pMeshbuffer->Material.MaterialType = irr::video::EMT_TRANSPARENT_VERTEX_ALPHA;
|
||||
pCurrMaterial->Meshbuffer->Material.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default: // comments or not recognised
|
||||
break;
|
||||
} // end switch(pBufPtr[0])
|
||||
} // end switch(bufPtr[0])
|
||||
// go to next line
|
||||
pBufPtr = goNextLine(pBufPtr, pBufEnd);
|
||||
} // end while (pBufPtr)
|
||||
bufPtr = goNextLine(bufPtr, pBufEnd);
|
||||
} // end while (bufPtr)
|
||||
|
||||
// end of file. if there's an existing material, store it
|
||||
if ( pCurrMaterial )
|
||||
|
@ -535,61 +529,61 @@ void COBJMeshFileLoader::readMTL(const c8* pFileName, core::stringc relPath)
|
|||
}
|
||||
|
||||
//! Read RGB color
|
||||
const c8* COBJMeshFileLoader::readColor(const c8* pBufPtr, video::SColor& color, const c8* const pBufEnd)
|
||||
const c8* COBJMeshFileLoader::readColor(const c8* bufPtr, video::SColor& color, const c8* const pBufEnd)
|
||||
{
|
||||
const u32 COLOR_BUFFER_LENGTH = 16;
|
||||
c8 colStr[COLOR_BUFFER_LENGTH];
|
||||
|
||||
color.setAlpha(255);
|
||||
pBufPtr = goAndCopyNextWord(colStr, pBufPtr, COLOR_BUFFER_LENGTH, pBufEnd);
|
||||
bufPtr = goAndCopyNextWord(colStr, bufPtr, COLOR_BUFFER_LENGTH, pBufEnd);
|
||||
color.setRed((s32)(core::fast_atof(colStr) * 255.0f));
|
||||
pBufPtr = goAndCopyNextWord(colStr, pBufPtr, COLOR_BUFFER_LENGTH, pBufEnd);
|
||||
bufPtr = goAndCopyNextWord(colStr, bufPtr, COLOR_BUFFER_LENGTH, pBufEnd);
|
||||
color.setGreen((s32)(core::fast_atof(colStr) * 255.0f));
|
||||
pBufPtr = goAndCopyNextWord(colStr, pBufPtr, COLOR_BUFFER_LENGTH, pBufEnd);
|
||||
bufPtr = goAndCopyNextWord(colStr, bufPtr, COLOR_BUFFER_LENGTH, pBufEnd);
|
||||
color.setBlue((s32)(core::fast_atof(colStr) * 255.0f));
|
||||
return pBufPtr;
|
||||
return bufPtr;
|
||||
}
|
||||
|
||||
|
||||
//! Read 3d vector of floats
|
||||
const c8* COBJMeshFileLoader::readVec3(const c8* pBufPtr, core::vector3df& vec, const c8* const pBufEnd)
|
||||
const c8* COBJMeshFileLoader::readVec3(const c8* bufPtr, core::vector3df& vec, const c8* const pBufEnd)
|
||||
{
|
||||
const u32 WORD_BUFFER_LENGTH = 256;
|
||||
c8 wordBuffer[WORD_BUFFER_LENGTH];
|
||||
|
||||
pBufPtr = goAndCopyNextWord(wordBuffer, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
bufPtr = goAndCopyNextWord(wordBuffer, bufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
vec.X=-core::fast_atof(wordBuffer); // change handedness
|
||||
pBufPtr = goAndCopyNextWord(wordBuffer, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
bufPtr = goAndCopyNextWord(wordBuffer, bufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
vec.Y=core::fast_atof(wordBuffer);
|
||||
pBufPtr = goAndCopyNextWord(wordBuffer, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
bufPtr = goAndCopyNextWord(wordBuffer, bufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
vec.Z=core::fast_atof(wordBuffer);
|
||||
return pBufPtr;
|
||||
return bufPtr;
|
||||
}
|
||||
|
||||
|
||||
//! Read 2d vector of floats
|
||||
const c8* COBJMeshFileLoader::readVec2(const c8* pBufPtr, core::vector2df& vec, const c8* const pBufEnd)
|
||||
const c8* COBJMeshFileLoader::readVec2(const c8* bufPtr, core::vector2df& vec, const c8* const pBufEnd)
|
||||
{
|
||||
const u32 WORD_BUFFER_LENGTH = 256;
|
||||
c8 wordBuffer[WORD_BUFFER_LENGTH];
|
||||
|
||||
pBufPtr = goAndCopyNextWord(wordBuffer, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
bufPtr = goAndCopyNextWord(wordBuffer, bufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
vec.X=core::fast_atof(wordBuffer);
|
||||
pBufPtr = goAndCopyNextWord(wordBuffer, pBufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
bufPtr = goAndCopyNextWord(wordBuffer, bufPtr, WORD_BUFFER_LENGTH, pBufEnd);
|
||||
vec.Y=-core::fast_atof(wordBuffer); // change handedness
|
||||
return pBufPtr;
|
||||
return bufPtr;
|
||||
}
|
||||
|
||||
|
||||
//! Read boolean value represented as 'on' or 'off'
|
||||
const c8* COBJMeshFileLoader::readBool(const c8* pBufPtr, bool& tf, const c8* const pBufEnd)
|
||||
const c8* COBJMeshFileLoader::readBool(const c8* bufPtr, bool& tf, const c8* const pBufEnd)
|
||||
{
|
||||
const u32 BUFFER_LENGTH = 8;
|
||||
c8 tfStr[BUFFER_LENGTH];
|
||||
|
||||
pBufPtr = goAndCopyNextWord(tfStr, pBufPtr, BUFFER_LENGTH, pBufEnd);
|
||||
bufPtr = goAndCopyNextWord(tfStr, bufPtr, BUFFER_LENGTH, pBufEnd);
|
||||
tf = strcmp(tfStr, "off") != 0;
|
||||
return pBufPtr;
|
||||
return bufPtr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -769,7 +763,7 @@ void COBJMeshFileLoader::cleanUp()
|
|||
|
||||
for (i = 0; i < materials.size(); ++i )
|
||||
{
|
||||
materials[i]->pMeshbuffer->drop();
|
||||
materials[i]->Meshbuffer->drop();
|
||||
delete materials[i];
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include "IFileSystem.h"
|
||||
#include "IVideoDriver.h"
|
||||
#include "irrString.h"
|
||||
#include "SMesh.h"
|
||||
#include "SMeshBuffer.h"
|
||||
|
||||
namespace irr
|
||||
|
@ -17,7 +16,7 @@ namespace irr
|
|||
namespace scene
|
||||
{
|
||||
|
||||
//! Meshloader capable of loading 3ds meshes.
|
||||
//! Meshloader capable of loading obj meshes.
|
||||
class COBJMeshFileLoader : public IMeshLoader
|
||||
{
|
||||
public:
|
||||
|
@ -29,29 +28,30 @@ public:
|
|||
virtual ~COBJMeshFileLoader();
|
||||
|
||||
//! returns true if the file maybe is able to be loaded by this class
|
||||
//! based on the file extension (e.g. ".cob")
|
||||
//! based on the file extension (e.g. ".obj")
|
||||
virtual bool isALoadableFileExtension(const c8* fileName) const;
|
||||
|
||||
//! 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().
|
||||
//! See IReferenceCounted::drop() for more information.
|
||||
virtual IAnimatedMesh* createMesh(irr::io::IReadFile* file);
|
||||
virtual IAnimatedMesh* createMesh(io::IReadFile* file);
|
||||
|
||||
private:
|
||||
|
||||
struct SObjMtl
|
||||
{
|
||||
SObjMtl() : pMeshbuffer(0), illumination(0) {
|
||||
pMeshbuffer = new SMeshBuffer();
|
||||
pMeshbuffer->Material.Shininess = 0.0f;
|
||||
pMeshbuffer->Material.AmbientColor = video::SColorf(0.2f, 0.2f, 0.2f, 1.0f).toSColor();
|
||||
pMeshbuffer->Material.DiffuseColor = video::SColorf(0.8f, 0.8f, 0.8f, 1.0f).toSColor();
|
||||
pMeshbuffer->Material.SpecularColor = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f).toSColor();
|
||||
};
|
||||
SObjMtl(SObjMtl& o) : pMeshbuffer(o.pMeshbuffer), name(o.name), illumination(o.illumination) { o.pMeshbuffer->grab(); };
|
||||
SObjMtl() : Meshbuffer(0), illumination(0) {
|
||||
Meshbuffer = new SMeshBuffer();
|
||||
Meshbuffer->Material.Shininess = 0.0f;
|
||||
Meshbuffer->Material.AmbientColor = video::SColorf(0.2f, 0.2f, 0.2f, 1.0f).toSColor();
|
||||
Meshbuffer->Material.DiffuseColor = video::SColorf(0.8f, 0.8f, 0.8f, 1.0f).toSColor();
|
||||
Meshbuffer->Material.SpecularColor = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f).toSColor();
|
||||
}
|
||||
|
||||
scene::SMeshBuffer *pMeshbuffer;
|
||||
SObjMtl(SObjMtl& o) : Meshbuffer(o.Meshbuffer), name(o.name), illumination(o.illumination) { o.Meshbuffer->grab(); }
|
||||
|
||||
scene::SMeshBuffer *Meshbuffer;
|
||||
core::stringc name;
|
||||
c8 illumination;
|
||||
};
|
||||
|
@ -94,7 +94,6 @@ private:
|
|||
video::IVideoDriver* Driver;
|
||||
|
||||
core::array<SObjMtl*> materials;
|
||||
SMesh* Mesh;
|
||||
};
|
||||
|
||||
} // end namespace scene
|
||||
|
|
|
@ -47,7 +47,7 @@ COCTLoader::~COCTLoader()
|
|||
|
||||
|
||||
// Doesn't really belong here, but it's jammed in for now.
|
||||
void COCTLoader::OCTLoadLights(irr::io::IReadFile* file, irr::scene::ISceneManager * scene, irr::scene::ISceneNode * parent, f32 radius, f32 intensityScale, bool rewind)
|
||||
void COCTLoader::OCTLoadLights(io::IReadFile* file, scene::ISceneManager * scene, scene::ISceneNode * parent, f32 radius, f32 intensityScale, bool rewind)
|
||||
{
|
||||
if (rewind)
|
||||
file->seek(0);
|
||||
|
@ -86,7 +86,7 @@ core::vector3df COCTLoader::GetFaceNormal(f32 a[3], f32 b[3], f32 c[3]) {
|
|||
//! \return Pointer to the created mesh. Returns 0 if loading failed.
|
||||
//! If you no longer need the mesh, you should call IAnimatedMesh::drop().
|
||||
//! See IReferenceCounted::drop() for more information.
|
||||
IAnimatedMesh* COCTLoader::createMesh(irr::io::IReadFile* file)
|
||||
IAnimatedMesh* COCTLoader::createMesh(io::IReadFile* file)
|
||||
{
|
||||
if (!file)
|
||||
return 0;
|
||||
|
@ -160,7 +160,7 @@ IAnimatedMesh* COCTLoader::createMesh(irr::io::IReadFile* file)
|
|||
octVert * vv = &verts[faces[i].firstVert + v];
|
||||
video::S3DVertex2TCoords vert;
|
||||
vert.Pos.set(vv->pos[0], vv->pos[1], vv->pos[2]);
|
||||
vert.Color = irr::video::SColor(0,255,255,255);
|
||||
vert.Color = video::SColor(0,255,255,255);
|
||||
vert.Normal.set(normal);
|
||||
|
||||
if (textureID == 0)
|
||||
|
|
|
@ -59,7 +59,7 @@ namespace scene
|
|||
class COCTLoader : public IMeshLoader
|
||||
{
|
||||
public:
|
||||
void OCTLoadLights(irr::io::IReadFile* file, irr::scene::ISceneManager * scene, irr::scene::ISceneNode * parent = 0, f32 radius = 500.0f, f32 intensityScale = 0.0000001f*2.5, bool rewind = true);
|
||||
void OCTLoadLights(io::IReadFile* file, ISceneManager * scene, ISceneNode * parent = 0, f32 radius = 500.0f, f32 intensityScale = 0.0000001f*2.5, bool rewind = true);
|
||||
|
||||
//! constructor
|
||||
COCTLoader(video::IVideoDriver* driver);
|
||||
|
@ -75,7 +75,7 @@ namespace scene
|
|||
//! \return Pointer to the created mesh. Returns 0 if loading failed.
|
||||
//! If you no longer need the mesh, you should call IAnimatedMesh::drop().
|
||||
//! See IReferenceCounted::drop() for more information.
|
||||
virtual IAnimatedMesh* createMesh(irr::io::IReadFile* file);
|
||||
virtual IAnimatedMesh* createMesh(io::IReadFile* file);
|
||||
|
||||
private:
|
||||
core::vector3df GetFaceNormal(f32 a[3], f32 b[3], f32 c[3]);
|
||||
|
|
|
@ -95,7 +95,7 @@ c8* COSOperator::getTextFromClipboard() const
|
|||
}
|
||||
|
||||
|
||||
bool COSOperator::getProcessorSpeedMHz(irr::u32* MHz) const
|
||||
bool COSOperator::getProcessorSpeedMHz(u32* MHz) const
|
||||
{
|
||||
#if defined(_IRR_WINDOWS_API_)
|
||||
LONG Error;
|
||||
|
@ -137,7 +137,7 @@ bool COSOperator::getProcessorSpeedMHz(irr::u32* MHz) const
|
|||
#endif
|
||||
}
|
||||
|
||||
bool COSOperator::getSystemMemory(irr::u32* Total, irr::u32* Avail) const
|
||||
bool COSOperator::getSystemMemory(u32* Total, u32* Avail) const
|
||||
{
|
||||
#if defined(_IRR_WINDOWS_API_)
|
||||
MEMORYSTATUS MemoryStatus;
|
||||
|
@ -147,9 +147,9 @@ bool COSOperator::getSystemMemory(irr::u32* Total, irr::u32* Avail) const
|
|||
GlobalMemoryStatus(&MemoryStatus);
|
||||
|
||||
if (Total)
|
||||
*Total = (irr::u32)(MemoryStatus.dwTotalPhys>>10);
|
||||
*Total = (u32)(MemoryStatus.dwTotalPhys>>10);
|
||||
if (Avail)
|
||||
*Avail = (irr::u32)(MemoryStatus.dwAvailPhys>>10);
|
||||
*Avail = (u32)(MemoryStatus.dwAvailPhys>>10);
|
||||
|
||||
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
|
||||
return true;
|
||||
|
|
|
@ -32,13 +32,13 @@ public:
|
|||
//! gets the processor speed in megahertz
|
||||
//! \param Mhz:
|
||||
//! \return Returns true if successful, false if not
|
||||
virtual bool getProcessorSpeedMHz(irr::u32* MHz) const;
|
||||
virtual bool getProcessorSpeedMHz(u32* MHz) const;
|
||||
|
||||
//! gets the total and available system RAM in kB
|
||||
//! \param Total: will contain the total system memory
|
||||
//! \param Avail: will contain the available memory
|
||||
//! \return Returns true if successful, false if not
|
||||
virtual bool getSystemMemory(irr::u32* Total, irr::u32* Avail) const;
|
||||
virtual bool getSystemMemory(u32* Total, u32* Avail) const;
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ public:
|
|||
//! \return Pointer to the created mesh. Returns 0 if loading failed.
|
||||
//! If you no longer need the mesh, you should call IAnimatedMesh::drop().
|
||||
//! See IReferenceCounted::drop() for more information.
|
||||
virtual IAnimatedMesh* createMesh(irr::io::IReadFile* file);
|
||||
virtual IAnimatedMesh* createMesh(io::IReadFile* file);
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -2093,6 +2093,7 @@ IGPUProgrammingServices* COpenGLDriver::getGPUProgrammingServices()
|
|||
return this;
|
||||
}
|
||||
|
||||
|
||||
ITexture* COpenGLDriver::createRenderTargetTexture(const core::dimension2d<s32>& size, const c8* name)
|
||||
{
|
||||
//disable mip-mapping
|
||||
|
@ -2154,7 +2155,9 @@ bool COpenGLDriver::setRenderTarget(video::ITexture* texture, bool clearBackBuff
|
|||
if (RenderTargetTexture!=0)
|
||||
{
|
||||
if (RenderTargetTexture->isFrameBufferObject())
|
||||
{
|
||||
RenderTargetTexture->unbindFrameBufferObject();
|
||||
}
|
||||
else
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, RenderTargetTexture->getOpenGLTextureName());
|
||||
|
@ -2173,7 +2176,9 @@ bool COpenGLDriver::setRenderTarget(video::ITexture* texture, bool clearBackBuff
|
|||
CurrentRendertargetSize = texture->getSize();
|
||||
|
||||
if (RenderTargetTexture->isFrameBufferObject())
|
||||
{
|
||||
RenderTargetTexture->bindFrameBufferObject();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2185,7 +2190,7 @@ bool COpenGLDriver::setRenderTarget(video::ITexture* texture, bool clearBackBuff
|
|||
GLbitfield mask = 0;
|
||||
if (clearBackBuffer)
|
||||
{
|
||||
f32 inv = 1.0f / 255.0f;
|
||||
const f32 inv = 1.0f / 255.0f;
|
||||
glClearColor(color.getRed() * inv, color.getGreen() * inv,
|
||||
color.getBlue() * inv, color.getAlpha() * inv);
|
||||
|
||||
|
|
|
@ -149,6 +149,7 @@ COpenGLTexture::COpenGLTexture(const core::dimension2d<s32>& size,
|
|||
#endif
|
||||
}
|
||||
|
||||
|
||||
//! destructor
|
||||
COpenGLTexture::~COpenGLTexture()
|
||||
{
|
||||
|
|
|
@ -0,0 +1,265 @@
|
|||
// Copyright (C) 2007 Christian Stehno
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#include "IrrCompileConfig.h"
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_STL_LOADER_
|
||||
|
||||
#include "CSTLMeshFileLoader.h"
|
||||
#include "SMesh.h"
|
||||
#include "SMeshBuffer.h"
|
||||
#include "SAnimatedMesh.h"
|
||||
#include "IReadFile.h"
|
||||
#include "fast_atof.h"
|
||||
#include "coreutil.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace scene
|
||||
{
|
||||
|
||||
|
||||
//! returns true if the file maybe is able to be loaded by this class
|
||||
//! based on the file extension (e.g. ".bsp")
|
||||
bool CSTLMeshFileLoader::isALoadableFileExtension(const c8* filename) const
|
||||
{
|
||||
return strstr(filename, ".stl")!=0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! 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().
|
||||
//! See IReferenceCounted::drop() for more information.
|
||||
IAnimatedMesh* CSTLMeshFileLoader::createMesh(io::IReadFile* file)
|
||||
{
|
||||
const long filesize = file->getSize();
|
||||
if (filesize < 6) // we need a header
|
||||
return 0;
|
||||
|
||||
const u32 WORD_BUFFER_LENGTH = 512;
|
||||
|
||||
SMesh* mesh = new SMesh();
|
||||
mesh->addMeshBuffer( new SMeshBuffer() );
|
||||
|
||||
core::vector3df vertex[3];
|
||||
core::vector3df normal;
|
||||
|
||||
c8 buffer[WORD_BUFFER_LENGTH];
|
||||
|
||||
bool binary = false;
|
||||
file->read(buffer, 5);
|
||||
if (strncmp("solid", buffer, 5))
|
||||
binary = true;
|
||||
// read/skip header
|
||||
u32 binFaceCount = 0;
|
||||
if (binary)
|
||||
{
|
||||
file->seek(80);
|
||||
file->read(&binFaceCount, 4);
|
||||
#ifdef __BIG_ENDIAN__
|
||||
binFaceCount = os::Byteswap::byteswap(binFaceCount);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
goNextLine(file);
|
||||
|
||||
u16 attrib=0;
|
||||
core::stringc token;
|
||||
token.reserve(32);
|
||||
|
||||
while (file->getPos() < filesize)
|
||||
{
|
||||
if (!binary)
|
||||
{
|
||||
if (getNextToken(file, token) != "facet")
|
||||
{
|
||||
if (token=="endsolid")
|
||||
break;
|
||||
mesh->drop();
|
||||
return 0;
|
||||
}
|
||||
if (getNextToken(file, token) != "normal")
|
||||
{
|
||||
mesh->drop();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
getNextVector(file, normal, binary);
|
||||
if (!binary)
|
||||
{
|
||||
if (getNextToken(file, token) != "outer")
|
||||
{
|
||||
mesh->drop();
|
||||
return 0;
|
||||
}
|
||||
if (getNextToken(file, token) != "loop")
|
||||
{
|
||||
mesh->drop();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
for (u32 i=0; i<3; ++i)
|
||||
{
|
||||
if (!binary)
|
||||
{
|
||||
if (getNextToken(file, token) != "vertex")
|
||||
{
|
||||
mesh->drop();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
getNextVector(file, vertex[i], binary);
|
||||
}
|
||||
if (!binary)
|
||||
{
|
||||
if (getNextToken(file, token) != "endloop")
|
||||
{
|
||||
mesh->drop();
|
||||
return 0;
|
||||
}
|
||||
if (getNextToken(file, token) != "endfacet")
|
||||
{
|
||||
mesh->drop();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
file->read(&attrib, 2);
|
||||
#ifdef __BIG_ENDIAN__
|
||||
attrib = os::Byteswap::byteswap(attrib);
|
||||
#endif
|
||||
}
|
||||
|
||||
SMeshBuffer* mb = reinterpret_cast<SMeshBuffer*>(mesh->getMeshBuffer(mesh->getMeshBufferCount()-1));
|
||||
u32 vCount = mb->getVertexCount();
|
||||
video::SColor color(0xffffffff);
|
||||
if (attrib & 0x8000)
|
||||
color = video::A1R5G5B5toA8R8G8B8(attrib);
|
||||
mb->Vertices.push_back(video::S3DVertex(vertex[0],normal,color, core::vector2df()));
|
||||
mb->Vertices.push_back(video::S3DVertex(vertex[1],normal,color, core::vector2df()));
|
||||
mb->Vertices.push_back(video::S3DVertex(vertex[2],normal,color, core::vector2df()));
|
||||
mb->Indices.push_back(vCount);
|
||||
mb->Indices.push_back(vCount+1);
|
||||
mb->Indices.push_back(vCount+2);
|
||||
} // end while (file->getPos() < filesize)
|
||||
|
||||
// Create the Animated mesh if there's anything in the mesh
|
||||
SAnimatedMesh* pAM = 0;
|
||||
if ( 0 != mesh->getMeshBufferCount() )
|
||||
{
|
||||
mesh->recalculateBoundingBox();
|
||||
pAM = new SAnimatedMesh();
|
||||
pAM->Type = EAMT_OBJ;
|
||||
pAM->addMesh(mesh);
|
||||
pAM->recalculateBoundingBox();
|
||||
}
|
||||
|
||||
mesh->drop();
|
||||
|
||||
return pAM;
|
||||
}
|
||||
|
||||
|
||||
//! Read RGB color
|
||||
const c8* CSTLMeshFileLoader::readColor(const c8* bufPtr, video::SColor& color, const c8* const pBufEnd) const
|
||||
{
|
||||
const u32 COLOR_BUFFER_LENGTH = 16;
|
||||
c8 colStr[COLOR_BUFFER_LENGTH];
|
||||
|
||||
color.setAlpha(255);
|
||||
color.setRed((s32)(core::fast_atof(colStr) * 255.0f));
|
||||
color.setGreen((s32)(core::fast_atof(colStr) * 255.0f));
|
||||
color.setBlue((s32)(core::fast_atof(colStr) * 255.0f));
|
||||
return bufPtr;
|
||||
}
|
||||
|
||||
|
||||
//! Read 3d vector of floats
|
||||
void CSTLMeshFileLoader::getNextVector(io::IReadFile* file, core::vector3df& vec, bool binary) const
|
||||
{
|
||||
if (binary)
|
||||
{
|
||||
file->read(&vec.X, 4);
|
||||
file->read(&vec.Y, 4);
|
||||
file->read(&vec.Z, 4);
|
||||
#ifdef __BIG_ENDIAN__
|
||||
vec.X = os::Byteswap::byteswap(vec.X);
|
||||
vec.Y = os::Byteswap::byteswap(vec.Y);
|
||||
vec.Z = os::Byteswap::byteswap(vec.Z);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
goNextWord(file);
|
||||
core::stringc tmp;
|
||||
|
||||
getNextToken(file, tmp);
|
||||
core::fast_atof_move(tmp.c_str(), vec.X);
|
||||
getNextToken(file, tmp);
|
||||
core::fast_atof_move(tmp.c_str(), vec.Y);
|
||||
getNextToken(file, tmp);
|
||||
core::fast_atof_move(tmp.c_str(), vec.Z);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//! Read next word
|
||||
const core::stringc& CSTLMeshFileLoader::getNextToken(io::IReadFile* file, core::stringc& token) const
|
||||
{
|
||||
goNextWord(file);
|
||||
u8 c;
|
||||
token = "";
|
||||
while(file->getPos() != file->getSize())
|
||||
{
|
||||
file->read(&c, 1);
|
||||
// found it, so leave
|
||||
if (core::isspace(c))
|
||||
break;
|
||||
token.append(c);
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
||||
|
||||
//! skip to next word
|
||||
void CSTLMeshFileLoader::goNextWord(io::IReadFile* file) const
|
||||
{
|
||||
u8 c;
|
||||
while(file->getPos() != file->getSize())
|
||||
{
|
||||
file->read(&c, 1);
|
||||
// found it, so leave
|
||||
if (!core::isspace(c))
|
||||
{
|
||||
file->seek(-1, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//! Read until line break is reached and stop at the next non-space character
|
||||
void CSTLMeshFileLoader::goNextLine(io::IReadFile* file) const
|
||||
{
|
||||
u8 c;
|
||||
// look for newline characters
|
||||
while(file->getPos() != file->getSize())
|
||||
{
|
||||
file->read(&c, 1);
|
||||
// found it, so leave
|
||||
if (c=='\n' || c=='\r')
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
||||
|
||||
|
||||
#endif // _IRR_COMPILE_WITH_STL_LOADER_
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
// Copyright (C) 2007 Christian Stehno
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#ifndef __C_STL_MESH_FILE_LOADER_H_INCLUDED__
|
||||
#define __C_STL_MESH_FILE_LOADER_H_INCLUDED__
|
||||
|
||||
#include "IMeshLoader.h"
|
||||
#include "irrString.h"
|
||||
#include "SColor.h"
|
||||
#include "vector3d.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace scene
|
||||
{
|
||||
|
||||
//! Meshloader capable of loading STL meshes.
|
||||
class CSTLMeshFileLoader : public IMeshLoader
|
||||
{
|
||||
public:
|
||||
|
||||
//! returns true if the file maybe is able to be loaded by this class
|
||||
//! based on the file extension (i.e. ".stl")
|
||||
virtual bool isALoadableFileExtension(const c8* fileName) const;
|
||||
|
||||
//! 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().
|
||||
//! See IReferenceCounted::drop() for more information.
|
||||
virtual IAnimatedMesh* createMesh(io::IReadFile* file);
|
||||
|
||||
private:
|
||||
|
||||
// skips to the first non-space character available
|
||||
void goNextWord(io::IReadFile* file) const;
|
||||
// returns the next word
|
||||
const core::stringc& getNextToken(io::IReadFile* file, core::stringc& token) const;
|
||||
// skip to next printable character after the first line break
|
||||
void goNextLine(io::IReadFile* file) const;
|
||||
|
||||
//! Read RGB color
|
||||
const c8* readColor(const c8* pBufPtr, video::SColor& color, const c8* const pBufEnd) const;
|
||||
//! Read 3d vector of floats
|
||||
void getNextVector(io::IReadFile* file, core::vector3df& vec, bool binary) const;
|
||||
};
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,243 @@
|
|||
// Copyright (C) 2002-2007 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#include "IrrCompileConfig.h"
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_STL_WRITER_
|
||||
|
||||
#include "CSTLMeshWriter.h"
|
||||
#include "os.h"
|
||||
#include "IMesh.h"
|
||||
#include "IMeshBuffer.h"
|
||||
#include "IAttributes.h"
|
||||
#include "ISceneManager.h"
|
||||
#include "IMeshCache.h"
|
||||
#include "IWriteFile.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace scene
|
||||
{
|
||||
|
||||
CSTLMeshWriter::CSTLMeshWriter(scene::ISceneManager* smgr)
|
||||
: SceneManager(smgr)
|
||||
{
|
||||
if (SceneManager)
|
||||
SceneManager->grab();
|
||||
}
|
||||
|
||||
|
||||
CSTLMeshWriter::~CSTLMeshWriter()
|
||||
{
|
||||
if (SceneManager)
|
||||
SceneManager->drop();
|
||||
}
|
||||
|
||||
|
||||
//! Returns the type of the mesh writer
|
||||
EMESH_WRITER_TYPE CSTLMeshWriter::getType() const
|
||||
{
|
||||
return EMWT_STL;
|
||||
}
|
||||
|
||||
|
||||
//! writes a mesh
|
||||
bool CSTLMeshWriter::writeMesh(io::IWriteFile* file, scene::IMesh* mesh, s32 flags)
|
||||
{
|
||||
if (!file)
|
||||
return false;
|
||||
|
||||
os::Printer::log("Writing mesh", file->getFileName());
|
||||
|
||||
if (false)
|
||||
return writeMeshBinary(file, mesh, flags);
|
||||
else
|
||||
return writeMeshASCII(file, mesh, flags);
|
||||
}
|
||||
|
||||
|
||||
bool CSTLMeshWriter::writeMeshBinary(io::IWriteFile* file, scene::IMesh* mesh, s32 flags)
|
||||
{
|
||||
// write STL MESH header
|
||||
|
||||
file->write("binary ",7);
|
||||
const core::stringc name(SceneManager->getMeshCache()->getMeshFilename(mesh));
|
||||
const s32 sizeleft = 73-name.size(); // 80 byte header
|
||||
if (sizeleft<0)
|
||||
file->write(name.c_str(),73);
|
||||
else
|
||||
{
|
||||
char* buf = new char[80];
|
||||
memset(buf, 0, 80);
|
||||
file->write(name.c_str(),name.size());
|
||||
file->write(buf,sizeleft);
|
||||
delete [] buf;
|
||||
}
|
||||
u32 facenum = 0;
|
||||
for (u32 j=0; j<mesh->getMeshBufferCount(); ++j)
|
||||
facenum += mesh->getMeshBuffer(j)->getIndexCount()/3;
|
||||
file->write(&facenum,4);
|
||||
|
||||
// write mesh buffers
|
||||
|
||||
for (u32 i=0; i<mesh->getMeshBufferCount(); ++i)
|
||||
{
|
||||
IMeshBuffer* buffer = mesh->getMeshBuffer(i);
|
||||
if (buffer)
|
||||
{
|
||||
const u16 indexCount = buffer->getIndexCount();
|
||||
|
||||
switch(buffer->getVertexType())
|
||||
{
|
||||
case video::EVT_STANDARD:
|
||||
{
|
||||
video::S3DVertex* vtx = (video::S3DVertex*)buffer->getVertices();
|
||||
const u16 attributes = 0;
|
||||
for (u32 j=0; j<indexCount; j+=3)
|
||||
{
|
||||
file->write(&core::plane3df(vtx[buffer->getIndices()[j]].Pos,vtx[buffer->getIndices()[j+1]].Pos,vtx[buffer->getIndices()[j+2]].Pos).Normal, 12);
|
||||
file->write(&vtx[buffer->getIndices()[j]].Pos, 12);
|
||||
file->write(&vtx[buffer->getIndices()[j+1]].Pos, 12);
|
||||
file->write(&vtx[buffer->getIndices()[j+2]].Pos, 12);
|
||||
file->write(&attributes, 2);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case video::EVT_2TCOORDS:
|
||||
{
|
||||
video::S3DVertex2TCoords* vtx = (video::S3DVertex2TCoords*)buffer->getVertices();
|
||||
const u16 attributes = 0;
|
||||
for (u32 j=0; j<indexCount; j+=3)
|
||||
{
|
||||
file->write(&core::plane3df(vtx[buffer->getIndices()[j]].Pos,vtx[buffer->getIndices()[j+1]].Pos,vtx[buffer->getIndices()[j+2]].Pos).Normal, 12);
|
||||
file->write(&vtx[buffer->getIndices()[j]].Pos, 12);
|
||||
file->write(&vtx[buffer->getIndices()[j+1]].Pos, 12);
|
||||
file->write(&vtx[buffer->getIndices()[j+2]].Pos, 12);
|
||||
file->write(&attributes, 2);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case video::EVT_TANGENTS:
|
||||
{
|
||||
video::S3DVertexTangents* vtx = (video::S3DVertexTangents*)buffer->getVertices();
|
||||
const u16 attributes = 0;
|
||||
for (u32 j=0; j<indexCount; j+=3)
|
||||
{
|
||||
file->write(&core::plane3df(vtx[buffer->getIndices()[j]].Pos,vtx[buffer->getIndices()[j+1]].Pos,vtx[buffer->getIndices()[j+2]].Pos).Normal, 12);
|
||||
file->write(&vtx[buffer->getIndices()[j]].Pos, 12);
|
||||
file->write(&vtx[buffer->getIndices()[j+1]].Pos, 12);
|
||||
file->write(&vtx[buffer->getIndices()[j+2]].Pos, 12);
|
||||
file->write(&attributes, 2);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CSTLMeshWriter::writeMeshASCII(io::IWriteFile* file, scene::IMesh* mesh, s32 flags)
|
||||
{
|
||||
// write STL MESH header
|
||||
|
||||
file->write("solid ",6);
|
||||
const core::stringc name(SceneManager->getMeshCache()->getMeshFilename(mesh));
|
||||
file->write(name.c_str(),name.size());
|
||||
file->write("\n\n",2);
|
||||
|
||||
// write mesh buffers
|
||||
|
||||
for (u32 i=0; i<mesh->getMeshBufferCount(); ++i)
|
||||
{
|
||||
IMeshBuffer* buffer = mesh->getMeshBuffer(i);
|
||||
if (buffer)
|
||||
{
|
||||
const u16 indexCount = buffer->getIndexCount();
|
||||
|
||||
switch(buffer->getVertexType())
|
||||
{
|
||||
case video::EVT_STANDARD:
|
||||
{
|
||||
video::S3DVertex* vtx = (video::S3DVertex*)buffer->getVertices();
|
||||
for (u32 j=0; j<indexCount; j+=3)
|
||||
writeFace(file,
|
||||
vtx[buffer->getIndices()[j]].Pos,
|
||||
vtx[buffer->getIndices()[j+1]].Pos,
|
||||
vtx[buffer->getIndices()[j+2]].Pos);
|
||||
}
|
||||
break;
|
||||
case video::EVT_2TCOORDS:
|
||||
{
|
||||
video::S3DVertex2TCoords* vtx = (video::S3DVertex2TCoords*)buffer->getVertices();
|
||||
for (u32 j=0; j<indexCount; j+=3)
|
||||
writeFace(file,
|
||||
vtx[buffer->getIndices()[j]].Pos,
|
||||
vtx[buffer->getIndices()[j+1]].Pos,
|
||||
vtx[buffer->getIndices()[j+2]].Pos);
|
||||
}
|
||||
break;
|
||||
case video::EVT_TANGENTS:
|
||||
{
|
||||
video::S3DVertexTangents* vtx = (video::S3DVertexTangents*)buffer->getVertices();
|
||||
for (u32 j=0; j<indexCount; j+=3)
|
||||
writeFace(file,
|
||||
vtx[buffer->getIndices()[j]].Pos,
|
||||
vtx[buffer->getIndices()[j+1]].Pos,
|
||||
vtx[buffer->getIndices()[j+2]].Pos);
|
||||
}
|
||||
break;
|
||||
}
|
||||
file->write("\n",1);
|
||||
}
|
||||
}
|
||||
|
||||
file->write("endsolid ",9);
|
||||
file->write(name.c_str(),name.size());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void CSTLMeshWriter::getVectorAsStringLine(const core::vector3df& v, core::stringc& s) const
|
||||
{
|
||||
s = v.X;
|
||||
s += " ";
|
||||
s += v.Y;
|
||||
s += " ";
|
||||
s += v.Z;
|
||||
s += "\n";
|
||||
}
|
||||
|
||||
|
||||
void CSTLMeshWriter::writeFace(io::IWriteFile* file,
|
||||
const core::vector3df& v1,
|
||||
const core::vector3df& v2,
|
||||
const core::vector3df& v3)
|
||||
{
|
||||
core::stringc tmp;
|
||||
file->write("facet normal ",13);
|
||||
getVectorAsStringLine(core::plane3df(v1,v2,v3).Normal, tmp);
|
||||
file->write(tmp.c_str(),tmp.size());
|
||||
file->write(" outer loop\n",13);
|
||||
file->write(" vertex ",11);
|
||||
getVectorAsStringLine(v1, tmp);
|
||||
file->write(tmp.c_str(),tmp.size());
|
||||
file->write(" vertex ",11);
|
||||
getVectorAsStringLine(v2, tmp);
|
||||
file->write(tmp.c_str(),tmp.size());
|
||||
file->write(" vertex ",11);
|
||||
getVectorAsStringLine(v3, tmp);
|
||||
file->write(tmp.c_str(),tmp.size());
|
||||
file->write(" endloop\n",10);
|
||||
file->write("endfacet\n",9);
|
||||
}
|
||||
|
||||
|
||||
} // end namespace
|
||||
} // end namespace
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
// Copyright (C) 2002-2007 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#ifndef __IRR_STL_MESH_WRITER_H_INCLUDED__
|
||||
#define __IRR_STL_MESH_WRITER_H_INCLUDED__
|
||||
|
||||
#include "IMeshWriter.h"
|
||||
#include "S3DVertex.h"
|
||||
#include "irrString.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace scene
|
||||
{
|
||||
class IMeshBuffer;
|
||||
class ISceneManager;
|
||||
|
||||
//! class to write meshes, implementing a STL writer
|
||||
class CSTLMeshWriter : public IMeshWriter
|
||||
{
|
||||
public:
|
||||
|
||||
CSTLMeshWriter(scene::ISceneManager* smgr);
|
||||
virtual ~CSTLMeshWriter();
|
||||
|
||||
//! Returns the type of the mesh writer
|
||||
virtual EMESH_WRITER_TYPE getType() const;
|
||||
|
||||
//! writes a mesh
|
||||
virtual bool writeMesh(io::IWriteFile* file, scene::IMesh* mesh, s32 flags=EMWF_NONE);
|
||||
|
||||
protected:
|
||||
// write binary format
|
||||
bool writeMeshBinary(io::IWriteFile* file, scene::IMesh* mesh, s32 flags);
|
||||
|
||||
// write text format
|
||||
bool writeMeshASCII(io::IWriteFile* file, scene::IMesh* mesh, s32 flags);
|
||||
|
||||
// create vector output with line end into string
|
||||
void getVectorAsStringLine(const core::vector3df& v,
|
||||
core::stringc& s) const;
|
||||
|
||||
// write face information to file
|
||||
void writeFace(io::IWriteFile* file, const core::vector3df& v1,
|
||||
const core::vector3df& v2, const core::vector3df& v3);
|
||||
|
||||
scene::ISceneManager* SceneManager;
|
||||
};
|
||||
|
||||
} // end namespace
|
||||
} // end namespace
|
||||
|
||||
#endif
|
||||
|
|
@ -166,22 +166,20 @@ bool CSceneCollisionManager::getCollisionPoint(const core::line3d<f32>& ray,
|
|||
s32 cnt = 0;
|
||||
selector->getTriangles(Triangles.pointer(), totalcnt, cnt, ray);
|
||||
|
||||
core::vector3df linevect = ray.getVector().normalize();
|
||||
const core::vector3df linevect = ray.getVector().normalize();
|
||||
core::vector3df intersection;
|
||||
f32 nearest = 9999999999999.0f;
|
||||
bool found = false;
|
||||
f32 tmp, tmp2;
|
||||
f32 raylength = (f32)ray.getLengthSQ();
|
||||
const f32 raylength = ray.getLengthSQ();
|
||||
|
||||
for (s32 i=0; i<cnt; ++i)
|
||||
{
|
||||
if (Triangles[i].getIntersectionWithLine(ray.start, linevect, intersection))
|
||||
{
|
||||
tmp = (f32)intersection.getDistanceFromSQ(ray.start);
|
||||
tmp2 = (f32)intersection.getDistanceFromSQ(ray.end);
|
||||
const f32 tmp = intersection.getDistanceFromSQ(ray.start);
|
||||
const f32 tmp2 = intersection.getDistanceFromSQ(ray.end);
|
||||
|
||||
if (tmp < raylength && tmp2 < raylength &&
|
||||
tmp < nearest)
|
||||
if (tmp < raylength && tmp2 < raylength && tmp < nearest)
|
||||
{
|
||||
nearest = tmp;
|
||||
outTriangle = Triangles[i];
|
||||
|
|
|
@ -82,8 +82,21 @@
|
|||
#include "CB3DMeshFileLoader.h"
|
||||
#endif
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_STL_LOADER_
|
||||
#include "CSTLMeshFileLoader.h"
|
||||
#endif
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_COLLADA_WRITER_
|
||||
#include "CColladaMeshWriter.h"
|
||||
#endif
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_IRR_WRITER_
|
||||
#include "CIrrMeshWriter.h"
|
||||
#endif
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_STL_WRITER_
|
||||
#include "CSTLMeshWriter.h"
|
||||
#endif
|
||||
|
||||
#include "CCubeSceneNode.h"
|
||||
#include "CSphereSceneNode.h"
|
||||
|
@ -221,6 +234,9 @@ CSceneManager::CSceneManager(video::IVideoDriver* driver, io::IFileSystem* fs,
|
|||
#ifdef _IRR_COMPILE_WITH_B3D_LOADER_
|
||||
MeshLoaderList.push_back(new CB3DMeshFileLoader(this));
|
||||
#endif
|
||||
#ifdef _IRR_COMPILE_WITH_STL_LOADER_
|
||||
MeshLoaderList.push_back(new CSTLMeshFileLoader());
|
||||
#endif
|
||||
|
||||
// factories
|
||||
ISceneNodeFactory* factory = new CDefaultSceneNodeFactory(this);
|
||||
|
@ -1193,7 +1209,7 @@ void CSceneManager::drawAll()
|
|||
|
||||
LightList.sort (); // on distance to camera
|
||||
|
||||
u32 maxLights = irr::core::min_ ( Driver->getMaximalDynamicLightAmount (), LightList.size () );
|
||||
u32 maxLights = core::min_ ( Driver->getMaximalDynamicLightAmount (), LightList.size () );
|
||||
for (i=0; i< maxLights; ++i)
|
||||
LightList[i].node->render();
|
||||
|
||||
|
@ -2188,6 +2204,8 @@ IMeshWriter* CSceneManager::createMeshWriter(EMESH_WRITER_TYPE type)
|
|||
return new CIrrMeshWriter(Driver, FileSystem);
|
||||
case EMWT_COLLADA:
|
||||
return new CColladaMeshWriter(Driver, FileSystem);
|
||||
case EMWT_STL:
|
||||
return new CSTLMeshWriter(this);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include "irrString.h"
|
||||
#include "irrArray.h"
|
||||
#include "IMeshLoader.h"
|
||||
#include "IMeshWriter.h"
|
||||
#include "CAttributes.h"
|
||||
|
||||
namespace irr
|
||||
|
|
|
@ -37,7 +37,7 @@ CSoftwareDriver::CSoftwareDriver(const core::dimension2d<s32>& windowSize, bool
|
|||
|
||||
// create z buffer
|
||||
|
||||
ZBuffer = irr::video::createZBuffer(BackBuffer->getDimension());
|
||||
ZBuffer = video::createZBuffer(BackBuffer->getDimension());
|
||||
|
||||
// create triangle renderers
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ CSoftwareDriver2::CSoftwareDriver2(const core::dimension2d<s32>& windowSize, boo
|
|||
|
||||
// create z buffer
|
||||
|
||||
DepthBuffer = irr::video::createDepthBuffer(BackBuffer->getDimension());
|
||||
DepthBuffer = video::createDepthBuffer(BackBuffer->getDimension());
|
||||
|
||||
// create triangle renderers
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@ void CSphereSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttribute
|
|||
if (PolyCountX ==0 && PolyCountY == 0)
|
||||
PolyCountX = PolyCountY = polyCount;
|
||||
|
||||
Radius = irr::core::max_(Radius, 0.0001f);
|
||||
Radius = core::max_(Radius, 0.0001f);
|
||||
|
||||
if ( !core::equals(Radius, oldRadius) || PolyCountX != oldPolyCountX || PolyCountY != oldPolyCountY)
|
||||
{
|
||||
|
|
|
@ -139,8 +139,8 @@ void CTRGouraud2::scanline_bilinear ()
|
|||
#endif
|
||||
|
||||
// apply top-left fill-convention, left
|
||||
xStart = irr::core::ceil32( line.x[0] );
|
||||
xEnd = irr::core::ceil32( line.x[1] ) - 1;
|
||||
xStart = core::ceil32( line.x[0] );
|
||||
xEnd = core::ceil32( line.x[1] ) - 1;
|
||||
|
||||
dx = xEnd - xStart;
|
||||
|
||||
|
@ -365,8 +365,8 @@ void CTRGouraud2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4D
|
|||
#endif
|
||||
|
||||
// apply top-left fill convention, top part
|
||||
yStart = irr::core::ceil32( a->Pos.y );
|
||||
yEnd = irr::core::ceil32( b->Pos.y ) - 1;
|
||||
yStart = core::ceil32( a->Pos.y );
|
||||
yEnd = core::ceil32( b->Pos.y ) - 1;
|
||||
|
||||
#ifdef SUBTEXEL
|
||||
subPixel = ( (f32) yStart ) - a->Pos.y;
|
||||
|
@ -524,8 +524,8 @@ void CTRGouraud2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4D
|
|||
#endif
|
||||
|
||||
// apply top-left fill convention, top part
|
||||
yStart = irr::core::ceil32( b->Pos.y );
|
||||
yEnd = irr::core::ceil32( c->Pos.y ) - 1;
|
||||
yStart = core::ceil32( b->Pos.y );
|
||||
yEnd = core::ceil32( c->Pos.y ) - 1;
|
||||
|
||||
#ifdef SUBTEXEL
|
||||
|
||||
|
|
|
@ -142,8 +142,8 @@ void CTRGouraudAlpha2::scanline_bilinear ()
|
|||
#endif
|
||||
|
||||
// apply top-left fill-convention, left
|
||||
xStart = irr::core::ceil32( line.x[0] );
|
||||
xEnd = irr::core::ceil32( line.x[1] ) - 1;
|
||||
xStart = core::ceil32( line.x[0] );
|
||||
xEnd = core::ceil32( line.x[1] ) - 1;
|
||||
|
||||
dx = xEnd - xStart;
|
||||
|
||||
|
@ -377,8 +377,8 @@ void CTRGouraudAlpha2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,cons
|
|||
#endif
|
||||
|
||||
// apply top-left fill convention, top part
|
||||
yStart = irr::core::ceil32( a->Pos.y );
|
||||
yEnd = irr::core::ceil32( b->Pos.y ) - 1;
|
||||
yStart = core::ceil32( a->Pos.y );
|
||||
yEnd = core::ceil32( b->Pos.y ) - 1;
|
||||
|
||||
#ifdef SUBTEXEL
|
||||
subPixel = ( (f32) yStart ) - a->Pos.y;
|
||||
|
@ -536,8 +536,8 @@ void CTRGouraudAlpha2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,cons
|
|||
#endif
|
||||
|
||||
// apply top-left fill convention, top part
|
||||
yStart = irr::core::ceil32( b->Pos.y );
|
||||
yEnd = irr::core::ceil32( c->Pos.y ) - 1;
|
||||
yStart = core::ceil32( b->Pos.y );
|
||||
yEnd = core::ceil32( c->Pos.y ) - 1;
|
||||
|
||||
#ifdef SUBTEXEL
|
||||
|
||||
|
|
|
@ -141,8 +141,8 @@ void CTRGouraudAlphaNoZ2::scanline_bilinear ()
|
|||
#endif
|
||||
|
||||
// apply top-left fill-convention, left
|
||||
xStart = irr::core::ceil32( line.x[0] );
|
||||
xEnd = irr::core::ceil32( line.x[1] ) - 1;
|
||||
xStart = core::ceil32( line.x[0] );
|
||||
xEnd = core::ceil32( line.x[1] ) - 1;
|
||||
|
||||
dx = xEnd - xStart;
|
||||
|
||||
|
@ -379,8 +379,8 @@ void CTRGouraudAlphaNoZ2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,c
|
|||
#endif
|
||||
|
||||
// apply top-left fill convention, top part
|
||||
yStart = irr::core::ceil32( a->Pos.y );
|
||||
yEnd = irr::core::ceil32( b->Pos.y ) - 1;
|
||||
yStart = core::ceil32( a->Pos.y );
|
||||
yEnd = core::ceil32( b->Pos.y ) - 1;
|
||||
|
||||
#ifdef SUBTEXEL
|
||||
subPixel = ( (f32) yStart ) - a->Pos.y;
|
||||
|
@ -538,8 +538,8 @@ void CTRGouraudAlphaNoZ2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,c
|
|||
#endif
|
||||
|
||||
// apply top-left fill convention, top part
|
||||
yStart = irr::core::ceil32( b->Pos.y );
|
||||
yEnd = irr::core::ceil32( c->Pos.y ) - 1;
|
||||
yStart = core::ceil32( b->Pos.y );
|
||||
yEnd = core::ceil32( c->Pos.y ) - 1;
|
||||
|
||||
#ifdef SUBTEXEL
|
||||
|
||||
|
|
|
@ -151,8 +151,8 @@ void CTRTextureBlend::scanline_bilinear ()
|
|||
#endif
|
||||
|
||||
// apply top-left fill-convention, left
|
||||
xStart = irr::core::ceil32( line.x[0] );
|
||||
xEnd = irr::core::ceil32( line.x[1] ) - 1;
|
||||
xStart = core::ceil32( line.x[0] );
|
||||
xEnd = core::ceil32( line.x[1] ) - 1;
|
||||
|
||||
dx = xEnd - xStart;
|
||||
|
||||
|
@ -406,8 +406,8 @@ void CTRTextureBlend::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const
|
|||
#endif
|
||||
|
||||
// apply top-left fill convention, top part
|
||||
yStart = irr::core::ceil32( a->Pos.y );
|
||||
yEnd = irr::core::ceil32( b->Pos.y ) - 1;
|
||||
yStart = core::ceil32( a->Pos.y );
|
||||
yEnd = core::ceil32( b->Pos.y ) - 1;
|
||||
|
||||
#ifdef SUBTEXEL
|
||||
subPixel = ( (f32) yStart ) - a->Pos.y;
|
||||
|
@ -565,8 +565,8 @@ void CTRTextureBlend::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const
|
|||
#endif
|
||||
|
||||
// apply top-left fill convention, top part
|
||||
yStart = irr::core::ceil32( b->Pos.y );
|
||||
yEnd = irr::core::ceil32( c->Pos.y ) - 1;
|
||||
yStart = core::ceil32( b->Pos.y );
|
||||
yEnd = core::ceil32( c->Pos.y ) - 1;
|
||||
|
||||
#ifdef SUBTEXEL
|
||||
|
||||
|
|
|
@ -141,8 +141,8 @@ void CTRTextureDetailMap2::scanline_bilinear ()
|
|||
#endif
|
||||
|
||||
// apply top-left fill-convention, left
|
||||
xStart = irr::core::ceil32( line.x[0] );
|
||||
xEnd = irr::core::ceil32( line.x[1] ) - 1;
|
||||
xStart = core::ceil32( line.x[0] );
|
||||
xEnd = core::ceil32( line.x[1] ) - 1;
|
||||
|
||||
dx = xEnd - xStart;
|
||||
|
||||
|
@ -385,8 +385,8 @@ void CTRTextureDetailMap2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,
|
|||
#endif
|
||||
|
||||
// apply top-left fill convention, top part
|
||||
yStart = irr::core::ceil32( a->Pos.y );
|
||||
yEnd = irr::core::ceil32( b->Pos.y ) - 1;
|
||||
yStart = core::ceil32( a->Pos.y );
|
||||
yEnd = core::ceil32( b->Pos.y ) - 1;
|
||||
|
||||
#ifdef SUBTEXEL
|
||||
subPixel = ( (f32) yStart ) - a->Pos.y;
|
||||
|
@ -544,8 +544,8 @@ void CTRTextureDetailMap2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,
|
|||
#endif
|
||||
|
||||
// apply top-left fill convention, top part
|
||||
yStart = irr::core::ceil32( b->Pos.y );
|
||||
yEnd = irr::core::ceil32( c->Pos.y ) - 1;
|
||||
yStart = core::ceil32( b->Pos.y );
|
||||
yEnd = core::ceil32( c->Pos.y ) - 1;
|
||||
|
||||
#ifdef SUBTEXEL
|
||||
|
||||
|
|
|
@ -140,8 +140,8 @@ void CTRTextureGouraud2::scanline_bilinear ()
|
|||
#endif
|
||||
|
||||
// apply top-left fill-convention, left
|
||||
xStart = irr::core::ceil32( line.x[0] );
|
||||
xEnd = irr::core::ceil32( line.x[1] ) - 1;
|
||||
xStart = core::ceil32( line.x[0] );
|
||||
xEnd = core::ceil32( line.x[1] ) - 1;
|
||||
|
||||
dx = xEnd - xStart;
|
||||
|
||||
|
@ -397,8 +397,8 @@ void CTRTextureGouraud2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,co
|
|||
#endif
|
||||
|
||||
// apply top-left fill convention, top part
|
||||
yStart = irr::core::ceil32( a->Pos.y );
|
||||
yEnd = irr::core::ceil32( b->Pos.y ) - 1;
|
||||
yStart = core::ceil32( a->Pos.y );
|
||||
yEnd = core::ceil32( b->Pos.y ) - 1;
|
||||
|
||||
#ifdef SUBTEXEL
|
||||
subPixel = ( (f32) yStart ) - a->Pos.y;
|
||||
|
@ -556,8 +556,8 @@ void CTRTextureGouraud2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,co
|
|||
#endif
|
||||
|
||||
// apply top-left fill convention, top part
|
||||
yStart = irr::core::ceil32( b->Pos.y );
|
||||
yEnd = irr::core::ceil32( c->Pos.y ) - 1;
|
||||
yStart = core::ceil32( b->Pos.y );
|
||||
yEnd = core::ceil32( c->Pos.y ) - 1;
|
||||
|
||||
#ifdef SUBTEXEL
|
||||
|
||||
|
|
|
@ -140,8 +140,8 @@ void CTRTextureGouraudAdd2::scanline_bilinear ()
|
|||
#endif
|
||||
|
||||
// apply top-left fill-convention, left
|
||||
xStart = irr::core::ceil32( line.x[0] );
|
||||
xEnd = irr::core::ceil32( line.x[1] ) - 1;
|
||||
xStart = core::ceil32( line.x[0] );
|
||||
xEnd = core::ceil32( line.x[1] ) - 1;
|
||||
|
||||
dx = xEnd - xStart;
|
||||
|
||||
|
@ -404,8 +404,8 @@ void CTRTextureGouraudAdd2::drawTriangle ( const s4DVertex *a,const s4DVertex *b
|
|||
#endif
|
||||
|
||||
// apply top-left fill convention, top part
|
||||
yStart = irr::core::ceil32( a->Pos.y );
|
||||
yEnd = irr::core::ceil32( b->Pos.y ) - 1;
|
||||
yStart = core::ceil32( a->Pos.y );
|
||||
yEnd = core::ceil32( b->Pos.y ) - 1;
|
||||
|
||||
#ifdef SUBTEXEL
|
||||
subPixel = ( (f32) yStart ) - a->Pos.y;
|
||||
|
@ -563,8 +563,8 @@ void CTRTextureGouraudAdd2::drawTriangle ( const s4DVertex *a,const s4DVertex *b
|
|||
#endif
|
||||
|
||||
// apply top-left fill convention, top part
|
||||
yStart = irr::core::ceil32( b->Pos.y );
|
||||
yEnd = irr::core::ceil32( c->Pos.y ) - 1;
|
||||
yStart = core::ceil32( b->Pos.y );
|
||||
yEnd = core::ceil32( c->Pos.y ) - 1;
|
||||
|
||||
#ifdef SUBTEXEL
|
||||
|
||||
|
|
|
@ -140,8 +140,8 @@ void CTRTextureGouraudAddNoZ2::scanline_bilinear ()
|
|||
#endif
|
||||
|
||||
// apply top-left fill-convention, left
|
||||
xStart = irr::core::ceil32( line.x[0] );
|
||||
xEnd = irr::core::ceil32( line.x[1] ) - 1;
|
||||
xStart = core::ceil32( line.x[0] );
|
||||
xEnd = core::ceil32( line.x[1] ) - 1;
|
||||
|
||||
dx = xEnd - xStart;
|
||||
|
||||
|
@ -367,8 +367,8 @@ void CTRTextureGouraudAddNoZ2::drawTriangle ( const s4DVertex *a,const s4DVertex
|
|||
#endif
|
||||
|
||||
// apply top-left fill convention, top part
|
||||
yStart = irr::core::ceil32( a->Pos.y );
|
||||
yEnd = irr::core::ceil32( b->Pos.y ) - 1;
|
||||
yStart = core::ceil32( a->Pos.y );
|
||||
yEnd = core::ceil32( b->Pos.y ) - 1;
|
||||
|
||||
#ifdef SUBTEXEL
|
||||
subPixel = ( (f32) yStart ) - a->Pos.y;
|
||||
|
@ -526,8 +526,8 @@ void CTRTextureGouraudAddNoZ2::drawTriangle ( const s4DVertex *a,const s4DVertex
|
|||
#endif
|
||||
|
||||
// apply top-left fill convention, top part
|
||||
yStart = irr::core::ceil32( b->Pos.y );
|
||||
yEnd = irr::core::ceil32( c->Pos.y ) - 1;
|
||||
yStart = core::ceil32( b->Pos.y );
|
||||
yEnd = core::ceil32( c->Pos.y ) - 1;
|
||||
|
||||
#ifdef SUBTEXEL
|
||||
|
||||
|
|
|
@ -157,8 +157,8 @@ void CTRTextureGouraudAlpha2::scanline_bilinear ()
|
|||
#endif
|
||||
|
||||
// apply top-left fill-convention, left
|
||||
xStart = irr::core::ceil32( line.x[0] );
|
||||
xEnd = irr::core::ceil32( line.x[1] ) - 1;
|
||||
xStart = core::ceil32( line.x[0] );
|
||||
xEnd = core::ceil32( line.x[1] ) - 1;
|
||||
|
||||
dx = xEnd - xStart;
|
||||
|
||||
|
@ -427,8 +427,8 @@ void CTRTextureGouraudAlpha2::drawTriangle ( const s4DVertex *a,const s4DVertex
|
|||
#endif
|
||||
|
||||
// apply top-left fill convention, top part
|
||||
yStart = irr::core::ceil32( a->Pos.y );
|
||||
yEnd = irr::core::ceil32( b->Pos.y ) - 1;
|
||||
yStart = core::ceil32( a->Pos.y );
|
||||
yEnd = core::ceil32( b->Pos.y ) - 1;
|
||||
|
||||
#ifdef SUBTEXEL
|
||||
subPixel = ( (f32) yStart ) - a->Pos.y;
|
||||
|
@ -586,8 +586,8 @@ void CTRTextureGouraudAlpha2::drawTriangle ( const s4DVertex *a,const s4DVertex
|
|||
#endif
|
||||
|
||||
// apply top-left fill convention, top part
|
||||
yStart = irr::core::ceil32( b->Pos.y );
|
||||
yEnd = irr::core::ceil32( c->Pos.y ) - 1;
|
||||
yStart = core::ceil32( b->Pos.y );
|
||||
yEnd = core::ceil32( c->Pos.y ) - 1;
|
||||
|
||||
#ifdef SUBTEXEL
|
||||
|
||||
|
|
|
@ -157,8 +157,8 @@ void CTRTextureGouraudAlphaNoZ::scanline_bilinear ()
|
|||
#endif
|
||||
|
||||
// apply top-left fill-convention, left
|
||||
xStart = irr::core::ceil32( line.x[0] );
|
||||
xEnd = irr::core::ceil32( line.x[1] ) - 1;
|
||||
xStart = core::ceil32( line.x[0] );
|
||||
xEnd = core::ceil32( line.x[1] ) - 1;
|
||||
|
||||
dx = xEnd - xStart;
|
||||
|
||||
|
@ -427,8 +427,8 @@ void CTRTextureGouraudAlphaNoZ::drawTriangle ( const s4DVertex *a,const s4DVerte
|
|||
#endif
|
||||
|
||||
// apply top-left fill convention, top part
|
||||
yStart = irr::core::ceil32( a->Pos.y );
|
||||
yEnd = irr::core::ceil32( b->Pos.y ) - 1;
|
||||
yStart = core::ceil32( a->Pos.y );
|
||||
yEnd = core::ceil32( b->Pos.y ) - 1;
|
||||
|
||||
#ifdef SUBTEXEL
|
||||
subPixel = ( (f32) yStart ) - a->Pos.y;
|
||||
|
@ -586,8 +586,8 @@ void CTRTextureGouraudAlphaNoZ::drawTriangle ( const s4DVertex *a,const s4DVerte
|
|||
#endif
|
||||
|
||||
// apply top-left fill convention, top part
|
||||
yStart = irr::core::ceil32( b->Pos.y );
|
||||
yEnd = irr::core::ceil32( c->Pos.y ) - 1;
|
||||
yStart = core::ceil32( b->Pos.y );
|
||||
yEnd = core::ceil32( c->Pos.y ) - 1;
|
||||
|
||||
#ifdef SUBTEXEL
|
||||
|
||||
|
|
|
@ -145,8 +145,8 @@ void CTRTextureGouraudNoZ2::scanline_bilinear ( )
|
|||
#endif
|
||||
|
||||
// apply top-left fill-convention, left
|
||||
xStart = irr::core::ceil32( line.x[0] );
|
||||
xEnd = irr::core::ceil32( line.x[1] ) - 1;
|
||||
xStart = core::ceil32( line.x[0] );
|
||||
xEnd = core::ceil32( line.x[1] ) - 1;
|
||||
|
||||
dx = xEnd - xStart;
|
||||
|
||||
|
@ -225,7 +225,7 @@ void CTRTextureGouraudNoZ2::scanline_bilinear ( )
|
|||
tx0 = f32_to_fixPoint ( line.t0[0].x );
|
||||
ty0 = f32_to_fixPoint ( line.t0[0].y );
|
||||
#endif
|
||||
dst[i] = irr::getTexel_plain ( &IT[0], tx0, ty0 );
|
||||
dst[i] = getTexel_plain ( &IT[0], tx0, ty0 );
|
||||
|
||||
/*
|
||||
getSample_texture ( r0, g0, b0, &IT[0], tx0, ty0 );
|
||||
|
@ -370,8 +370,8 @@ void CTRTextureGouraudNoZ2::drawTriangle ( const s4DVertex *a,const s4DVertex *b
|
|||
#endif
|
||||
|
||||
// apply top-left fill convention, top part
|
||||
yStart = irr::core::ceil32( a->Pos.y );
|
||||
yEnd = irr::core::ceil32( b->Pos.y ) - 1;
|
||||
yStart = core::ceil32( a->Pos.y );
|
||||
yEnd = core::ceil32( b->Pos.y ) - 1;
|
||||
|
||||
#ifdef SUBTEXEL
|
||||
subPixel = ( (f32) yStart ) - a->Pos.y;
|
||||
|
@ -529,8 +529,8 @@ void CTRTextureGouraudNoZ2::drawTriangle ( const s4DVertex *a,const s4DVertex *b
|
|||
#endif
|
||||
|
||||
// apply top-left fill convention, top part
|
||||
yStart = irr::core::ceil32( b->Pos.y );
|
||||
yEnd = irr::core::ceil32( c->Pos.y ) - 1;
|
||||
yStart = core::ceil32( b->Pos.y );
|
||||
yEnd = core::ceil32( c->Pos.y ) - 1;
|
||||
|
||||
#ifdef SUBTEXEL
|
||||
|
||||
|
|
|
@ -139,8 +139,8 @@ void CTRTextureVertexAlpha2::scanline_bilinear ( )
|
|||
#endif
|
||||
|
||||
// apply top-left fill-convention, left
|
||||
xStart = irr::core::ceil32( line.x[0] );
|
||||
xEnd = irr::core::ceil32( line.x[1] ) - 1;
|
||||
xStart = core::ceil32( line.x[0] );
|
||||
xEnd = core::ceil32( line.x[1] ) - 1;
|
||||
|
||||
dx = xEnd - xStart;
|
||||
|
||||
|
@ -413,8 +413,8 @@ void CTRTextureVertexAlpha2::drawTriangle ( const s4DVertex *a,const s4DVertex *
|
|||
#endif
|
||||
|
||||
// apply top-left fill convention, top part
|
||||
yStart = irr::core::ceil32( a->Pos.y );
|
||||
yEnd = irr::core::ceil32( b->Pos.y ) - 1;
|
||||
yStart = core::ceil32( a->Pos.y );
|
||||
yEnd = core::ceil32( b->Pos.y ) - 1;
|
||||
|
||||
#ifdef SUBTEXEL
|
||||
subPixel = ( (f32) yStart ) - a->Pos.y;
|
||||
|
@ -572,8 +572,8 @@ void CTRTextureVertexAlpha2::drawTriangle ( const s4DVertex *a,const s4DVertex *
|
|||
#endif
|
||||
|
||||
// apply top-left fill convention, top part
|
||||
yStart = irr::core::ceil32( b->Pos.y );
|
||||
yEnd = irr::core::ceil32( c->Pos.y ) - 1;
|
||||
yStart = core::ceil32( b->Pos.y );
|
||||
yEnd = core::ceil32( c->Pos.y ) - 1;
|
||||
|
||||
#ifdef SUBTEXEL
|
||||
|
||||
|
|
|
@ -140,8 +140,8 @@ REALINLINE void CTRTextureLightMap2_Add::scanline_bilinear ()
|
|||
#endif
|
||||
|
||||
// apply top-left fill-convention, left
|
||||
xStart = irr::core::ceil32( line.x[0] );
|
||||
xEnd = irr::core::ceil32( line.x[1] ) - 1;
|
||||
xStart = core::ceil32( line.x[0] );
|
||||
xEnd = core::ceil32( line.x[1] ) - 1;
|
||||
|
||||
dx = xEnd - xStart;
|
||||
|
||||
|
@ -398,8 +398,8 @@ void CTRTextureLightMap2_Add::drawTriangle ( const s4DVertex *a,const s4DVertex
|
|||
#endif
|
||||
|
||||
// apply top-left fill convention, top part
|
||||
yStart = irr::core::ceil32( a->Pos.y );
|
||||
yEnd = irr::core::ceil32( b->Pos.y ) - 1;
|
||||
yStart = core::ceil32( a->Pos.y );
|
||||
yEnd = core::ceil32( b->Pos.y ) - 1;
|
||||
|
||||
#ifdef SUBTEXEL
|
||||
subPixel = ( (f32) yStart ) - a->Pos.y;
|
||||
|
@ -557,8 +557,8 @@ void CTRTextureLightMap2_Add::drawTriangle ( const s4DVertex *a,const s4DVertex
|
|||
#endif
|
||||
|
||||
// apply top-left fill convention, top part
|
||||
yStart = irr::core::ceil32( b->Pos.y );
|
||||
yEnd = irr::core::ceil32( c->Pos.y ) - 1;
|
||||
yStart = core::ceil32( b->Pos.y );
|
||||
yEnd = core::ceil32( c->Pos.y ) - 1;
|
||||
|
||||
#ifdef SUBTEXEL
|
||||
|
||||
|
|
|
@ -115,8 +115,8 @@ REALINLINE void CTRTextureLightMap2_M1::scanline_bilinear2 ()
|
|||
|
||||
|
||||
// apply top-left fill-convention, left
|
||||
xStart = irr::core::ceil32( line.x[0] );
|
||||
xEnd = irr::core::ceil32( line.x[1] ) - 1;
|
||||
xStart = core::ceil32( line.x[0] );
|
||||
xEnd = core::ceil32( line.x[1] ) - 1;
|
||||
|
||||
dx = xEnd - xStart;
|
||||
if ( dx < 0 )
|
||||
|
@ -371,8 +371,8 @@ void CTRTextureLightMap2_M1::drawTriangle ( const s4DVertex *a,const s4DVertex *
|
|||
#endif
|
||||
|
||||
// apply top-left fill convention, top part
|
||||
yStart = irr::core::ceil32( a->Pos.y );
|
||||
yEnd = irr::core::ceil32( b->Pos.y ) - 1;
|
||||
yStart = core::ceil32( a->Pos.y );
|
||||
yEnd = core::ceil32( b->Pos.y ) - 1;
|
||||
|
||||
#ifdef SUBTEXEL
|
||||
subPixel = ( (f32) yStart ) - a->Pos.y;
|
||||
|
@ -531,8 +531,8 @@ void CTRTextureLightMap2_M1::drawTriangle ( const s4DVertex *a,const s4DVertex *
|
|||
#endif
|
||||
|
||||
// apply top-left fill convention, top part
|
||||
yStart = irr::core::ceil32( b->Pos.y );
|
||||
yEnd = irr::core::ceil32( c->Pos.y ) - 1;
|
||||
yStart = core::ceil32( b->Pos.y );
|
||||
yEnd = core::ceil32( c->Pos.y ) - 1;
|
||||
|
||||
#ifdef SUBTEXEL
|
||||
|
||||
|
|
|
@ -115,8 +115,8 @@ REALINLINE void CTRTextureLightMap2_M2::scanline_bilinear2 ()
|
|||
|
||||
|
||||
// apply top-left fill-convention, left
|
||||
xStart = irr::core::ceil32( line.x[0] );
|
||||
xEnd = irr::core::ceil32( line.x[1] ) - 1;
|
||||
xStart = core::ceil32( line.x[0] );
|
||||
xEnd = core::ceil32( line.x[1] ) - 1;
|
||||
|
||||
dx = xEnd - xStart;
|
||||
if ( dx < 0 )
|
||||
|
@ -364,8 +364,8 @@ void CTRTextureLightMap2_M2::drawTriangle ( const s4DVertex *a,const s4DVertex *
|
|||
#endif
|
||||
|
||||
// apply top-left fill convention, top part
|
||||
yStart = irr::core::ceil32( a->Pos.y );
|
||||
yEnd = irr::core::ceil32( b->Pos.y ) - 1;
|
||||
yStart = core::ceil32( a->Pos.y );
|
||||
yEnd = core::ceil32( b->Pos.y ) - 1;
|
||||
|
||||
#ifdef SUBTEXEL
|
||||
subPixel = ( (f32) yStart ) - a->Pos.y;
|
||||
|
@ -524,8 +524,8 @@ void CTRTextureLightMap2_M2::drawTriangle ( const s4DVertex *a,const s4DVertex *
|
|||
#endif
|
||||
|
||||
// apply top-left fill convention, top part
|
||||
yStart = irr::core::ceil32( b->Pos.y );
|
||||
yEnd = irr::core::ceil32( c->Pos.y ) - 1;
|
||||
yStart = core::ceil32( b->Pos.y );
|
||||
yEnd = core::ceil32( c->Pos.y ) - 1;
|
||||
|
||||
#ifdef SUBTEXEL
|
||||
|
||||
|
|
|
@ -121,8 +121,8 @@ REALINLINE void CTRTextureLightMap2_M4::scanline_bilinear2_mag ()
|
|||
|
||||
|
||||
// apply top-left fill-convention, left
|
||||
xStart = irr::core::ceil32( line.x[0] );
|
||||
xEnd = irr::core::ceil32( line.x[1] ) - 1;
|
||||
xStart = core::ceil32( line.x[0] );
|
||||
xEnd = core::ceil32( line.x[1] ) - 1;
|
||||
|
||||
dx = xEnd - xStart;
|
||||
if ( dx < 0 )
|
||||
|
@ -265,8 +265,8 @@ REALINLINE void CTRTextureLightMap2_M4::scanline_bilinear2_min ()
|
|||
|
||||
|
||||
// apply top-left fill-convention, left
|
||||
xStart = irr::core::ceil32( line.x[0] );
|
||||
xEnd = irr::core::ceil32( line.x[1] ) - 1;
|
||||
xStart = core::ceil32( line.x[0] );
|
||||
xEnd = core::ceil32( line.x[1] ) - 1;
|
||||
|
||||
dx = xEnd - xStart;
|
||||
if ( dx < 0 )
|
||||
|
@ -414,8 +414,8 @@ REALINLINE void CTRTextureLightMap2_M4::scanline_bilinear ()
|
|||
#endif
|
||||
|
||||
// apply top-left fill-convention, left
|
||||
xStart = irr::core::ceil32( line.x[0] );
|
||||
xEnd = irr::core::ceil32( line.x[1] ) - 1;
|
||||
xStart = core::ceil32( line.x[0] );
|
||||
xEnd = core::ceil32( line.x[1] ) - 1;
|
||||
|
||||
dx = xEnd - xStart;
|
||||
|
||||
|
@ -693,8 +693,8 @@ void CTRTextureLightMap2_M4::drawTriangle_Min ( const s4DVertex *a,const s4DVert
|
|||
#endif
|
||||
|
||||
// apply top-left fill convention, top part
|
||||
yStart = irr::core::ceil32( a->Pos.y );
|
||||
yEnd = irr::core::ceil32( b->Pos.y ) - 1;
|
||||
yStart = core::ceil32( a->Pos.y );
|
||||
yEnd = core::ceil32( b->Pos.y ) - 1;
|
||||
|
||||
#ifdef SUBTEXEL
|
||||
subPixel = ( (f32) yStart ) - a->Pos.y;
|
||||
|
@ -853,8 +853,8 @@ void CTRTextureLightMap2_M4::drawTriangle_Min ( const s4DVertex *a,const s4DVert
|
|||
#endif
|
||||
|
||||
// apply top-left fill convention, top part
|
||||
yStart = irr::core::ceil32( b->Pos.y );
|
||||
yEnd = irr::core::ceil32( c->Pos.y ) - 1;
|
||||
yStart = core::ceil32( b->Pos.y );
|
||||
yEnd = core::ceil32( c->Pos.y ) - 1;
|
||||
|
||||
#ifdef SUBTEXEL
|
||||
|
||||
|
@ -1096,8 +1096,8 @@ void CTRTextureLightMap2_M4::drawTriangle ( const s4DVertex *a,const s4DVertex *
|
|||
#endif
|
||||
|
||||
// apply top-left fill convention, top part
|
||||
yStart = irr::core::ceil32( a->Pos.y );
|
||||
yEnd = irr::core::ceil32( b->Pos.y ) - 1;
|
||||
yStart = core::ceil32( a->Pos.y );
|
||||
yEnd = core::ceil32( b->Pos.y ) - 1;
|
||||
|
||||
#ifdef SUBTEXEL
|
||||
subPixel = ( (f32) yStart ) - a->Pos.y;
|
||||
|
@ -1256,8 +1256,8 @@ void CTRTextureLightMap2_M4::drawTriangle ( const s4DVertex *a,const s4DVertex *
|
|||
#endif
|
||||
|
||||
// apply top-left fill convention, top part
|
||||
yStart = irr::core::ceil32( b->Pos.y );
|
||||
yEnd = irr::core::ceil32( c->Pos.y ) - 1;
|
||||
yStart = core::ceil32( b->Pos.y );
|
||||
yEnd = core::ceil32( c->Pos.y ) - 1;
|
||||
|
||||
#ifdef SUBTEXEL
|
||||
|
||||
|
|
|
@ -140,8 +140,8 @@ void CTRGTextureLightMap2_M4::scanline_bilinear ()
|
|||
#endif
|
||||
|
||||
// apply top-left fill-convention, left
|
||||
xStart = irr::core::ceil32( line.x[0] );
|
||||
xEnd = irr::core::ceil32( line.x[1] ) - 1;
|
||||
xStart = core::ceil32( line.x[0] );
|
||||
xEnd = core::ceil32( line.x[1] ) - 1;
|
||||
|
||||
dx = xEnd - xStart;
|
||||
|
||||
|
@ -408,8 +408,8 @@ void CTRGTextureLightMap2_M4::drawTriangle ( const s4DVertex *a,const s4DVertex
|
|||
#endif
|
||||
|
||||
// apply top-left fill convention, top part
|
||||
yStart = irr::core::ceil32( a->Pos.y );
|
||||
yEnd = irr::core::ceil32( b->Pos.y ) - 1;
|
||||
yStart = core::ceil32( a->Pos.y );
|
||||
yEnd = core::ceil32( b->Pos.y ) - 1;
|
||||
|
||||
#ifdef SUBTEXEL
|
||||
subPixel = ( (f32) yStart ) - a->Pos.y;
|
||||
|
@ -569,8 +569,8 @@ void CTRGTextureLightMap2_M4::drawTriangle ( const s4DVertex *a,const s4DVertex
|
|||
#endif
|
||||
|
||||
// apply top-left fill convention, top part
|
||||
yStart = irr::core::ceil32( b->Pos.y );
|
||||
yEnd = irr::core::ceil32( c->Pos.y ) - 1;
|
||||
yStart = core::ceil32( b->Pos.y );
|
||||
yEnd = core::ceil32( c->Pos.y ) - 1;
|
||||
|
||||
#ifdef SUBTEXEL
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ bool CXMeshFileLoader::isALoadableFileExtension(const c8* filename) const
|
|||
//! \return Pointer to the created mesh. Returns 0 if loading failed.
|
||||
//! If you no longer need the mesh, you should call IAnimatedMesh::drop().
|
||||
//! See IReferenceCounted::drop() for more information.
|
||||
IAnimatedMesh* CXMeshFileLoader::createMesh(irr::io::IReadFile* f)
|
||||
IAnimatedMesh* CXMeshFileLoader::createMesh(io::IReadFile* f)
|
||||
{
|
||||
if (!f)
|
||||
return 0;
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
//! \return Pointer to the created mesh. Returns 0 if loading failed.
|
||||
//! If you no longer need the mesh, you should call IAnimatedMesh::drop().
|
||||
//! See IReferenceCounted::drop() for more information.
|
||||
virtual IAnimatedMesh* createMesh(irr::io::IReadFile* file);
|
||||
virtual IAnimatedMesh* createMesh(io::IReadFile* file);
|
||||
|
||||
struct SXTemplateMaterial
|
||||
{
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace irr
|
|||
bool stencilbuffer, bool vsync, IEventReceiver* res,
|
||||
const char* version)
|
||||
{
|
||||
irr::SIrrlichtCreationParameters p;
|
||||
SIrrlichtCreationParameters p;
|
||||
p.DriverType = driverType;
|
||||
p.WindowSize = windowSize;
|
||||
p.Bits = bits;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue