Commit c4ec0b52 authored by hybrid's avatar hybrid

Fixed Ogre file format check to support new version. Fixed some missing inits....

Fixed Ogre file format check to support new version. Fixed some missing inits. Changed some tests to switch statements.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@679 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 480ba9cc
...@@ -683,7 +683,7 @@ f32 CAttributes::getAttributeAsFloat(s32 index) ...@@ -683,7 +683,7 @@ f32 CAttributes::getAttributeAsFloat(s32 index)
//! \param index: Index value, must be between 0 and getAttributeCount()-1. //! \param index: Index value, must be between 0 and getAttributeCount()-1.
video::SColor CAttributes::getAttributeAsColor(s32 index) video::SColor CAttributes::getAttributeAsColor(s32 index)
{ {
video::SColor ret; video::SColor ret(0);
if (index >= 0 && index < (s32)Attributes.size()) if (index >= 0 && index < (s32)Attributes.size())
ret = Attributes[index]->getColor(); ret = Attributes[index]->getColor();
......
...@@ -893,6 +893,7 @@ void CColladaFileLoader::readPolygonSection(io::IXMLReaderUTF8* reader, ...@@ -893,6 +893,7 @@ void CColladaFileLoader::readPolygonSection(io::IXMLReaderUTF8* reader,
if (!Inputs.empty()) if (!Inputs.empty())
{ {
SInputSlot slot; SInputSlot slot;
slot.Data=0;
slot.Semantic = Inputs.getLast().Semantic; slot.Semantic = Inputs.getLast().Semantic;
core::stringc sourceArrayURI; core::stringc sourceArrayURI;
......
...@@ -101,9 +101,8 @@ void jpeg_memory_dest (j_compress_ptr cinfo, u8 *jfif_buffer, ...@@ -101,9 +101,8 @@ void jpeg_memory_dest (j_compress_ptr cinfo, u8 *jfif_buffer,
/* write_JPEG_memory: store JPEG compressed image into memory. /* write_JPEG_memory: store JPEG compressed image into memory.
*/ */
void write_JPEG_memory (void *img_buf, s32 width, s32 height, u32 bpp, u32 pitch, void write_JPEG_memory (void *img_buf, s32 width, s32 height, u32 bpp, u32 pitch,
u8 *jpeg_buffer, u32 jpeg_buffer_size, u8 *jpeg_buffer, u32 jpeg_buffer_size,
s32 quality, u32 *jpeg_comp_size s32 quality, u32 *jpeg_comp_size)
)
{ {
struct jpeg_compress_struct cinfo; struct jpeg_compress_struct cinfo;
struct jpeg_error_mgr jerr; struct jpeg_error_mgr jerr;
...@@ -111,7 +110,6 @@ void write_JPEG_memory (void *img_buf, s32 width, s32 height, u32 bpp, u32 pitch ...@@ -111,7 +110,6 @@ void write_JPEG_memory (void *img_buf, s32 width, s32 height, u32 bpp, u32 pitch
/* More stuff */ /* More stuff */
JSAMPROW row_pointer[1]; /* pointer to JSAMPLE row[s] */ JSAMPROW row_pointer[1]; /* pointer to JSAMPLE row[s] */
cinfo.err = jpeg_std_error(&jerr); cinfo.err = jpeg_std_error(&jerr);
jpeg_create_compress(&cinfo); jpeg_create_compress(&cinfo);
jpeg_memory_dest(&cinfo, jpeg_buffer, jpeg_buffer_size); jpeg_memory_dest(&cinfo, jpeg_buffer, jpeg_buffer_size);
...@@ -197,7 +195,7 @@ bool CImageWriterJPG::writeImage(io::IWriteFile *file, IImage *input,u32 quality ...@@ -197,7 +195,7 @@ bool CImageWriterJPG::writeImage(io::IWriteFile *file, IImage *input,u32 quality
void *dst = image->lock(); void *dst = image->lock();
for ( y = 0; y!= dim.Height; ++y ) for ( y = 0; y!= dim.Height; ++y )
{ {
format ( src, dim.Width, dst ); format( src, dim.Width, dst );
src = (void*) ( (u8*) src + input->getPitch () ); src = (void*) ( (u8*) src + input->getPitch () );
dst = (void*) ( (u8*) dst + image->getPitch () ); dst = (void*) ( (u8*) dst + image->getPitch () );
} }
...@@ -212,11 +210,10 @@ bool CImageWriterJPG::writeImage(io::IWriteFile *file, IImage *input,u32 quality ...@@ -212,11 +210,10 @@ bool CImageWriterJPG::writeImage(io::IWriteFile *file, IImage *input,u32 quality
quality = 75; quality = 75;
write_JPEG_memory ( image->lock (), dim.Width, dim.Height, write_JPEG_memory ( image->lock (), dim.Width, dim.Height,
image->getBytesPerPixel(), image->getPitch (), image->getBytesPerPixel(), image->getPitch(),
dest, destSize, dest, destSize,
quality, quality,
&destSize &destSize);
);
file->write ( dest, destSize ); file->write ( dest, destSize );
......
...@@ -96,16 +96,21 @@ bool CImageWriterPNG::writeImage(io::IWriteFile* file, IImage* image,u32 param) ...@@ -96,16 +96,21 @@ bool CImageWriterPNG::writeImage(io::IWriteFile* file, IImage* image,u32 param)
png_set_write_fn(png_ptr, file, user_write_data_fcn, NULL); png_set_write_fn(png_ptr, file, user_write_data_fcn, NULL);
// Set info // Set info
if ((image->getColorFormat()==ECF_A8R8G8B8) || (image->getColorFormat()==ECF_A1R5G5B5)) switch(image->getColorFormat())
png_set_IHDR(png_ptr, info_ptr, {
image->getDimension().Width, image->getDimension().Height, case ECF_A8R8G8B8:
8, PNG_COLOR_TYPE_RGB_ALPHA, PNG_INTERLACE_NONE, case ECF_A1R5G5B5:
PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); png_set_IHDR(png_ptr, info_ptr,
else image->getDimension().Width, image->getDimension().Height,
png_set_IHDR(png_ptr, info_ptr, 8, PNG_COLOR_TYPE_RGB_ALPHA, PNG_INTERLACE_NONE,
image->getDimension().Width, image->getDimension().Height, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, break;
PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); default:
png_set_IHDR(png_ptr, info_ptr,
image->getDimension().Width, image->getDimension().Height,
8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
}
s32 lineWidth=image->getDimension().Width; s32 lineWidth=image->getDimension().Width;
switch(image->getColorFormat()) switch(image->getColorFormat())
......
...@@ -56,7 +56,6 @@ inline void recalculateNormalsT_Smooth(VTXTYPE* v, int vtxcnt, ...@@ -56,7 +56,6 @@ inline void recalculateNormalsT_Smooth(VTXTYPE* v, int vtxcnt,
{ {
v[i].Normal.normalize (); v[i].Normal.normalize ();
} }
} }
...@@ -127,7 +126,7 @@ void CMeshManipulator::flipSurfaces(scene::IMesh* mesh) const ...@@ -127,7 +126,7 @@ void CMeshManipulator::flipSurfaces(scene::IMesh* mesh) const
for (u32 b=0; b<bcount; ++b) for (u32 b=0; b<bcount; ++b)
{ {
IMeshBuffer* buffer = mesh->getMeshBuffer(b); IMeshBuffer* buffer = mesh->getMeshBuffer(b);
u32 idxcnt = buffer->getIndexCount(); const u32 idxcnt = buffer->getIndexCount();
u16* idx = buffer->getIndices(); u16* idx = buffer->getIndices();
s32 tmp; s32 tmp;
...@@ -334,9 +333,7 @@ void CMeshManipulator::transformMesh(scene::IMesh* mesh, const core::matrix4& m) ...@@ -334,9 +333,7 @@ void CMeshManipulator::transformMesh(scene::IMesh* mesh, const core::matrix4& m)
meshbox.addInternalBox(buffer->getBoundingBox()); meshbox.addInternalBox(buffer->getBoundingBox());
} }
mesh->setBoundingBox( meshbox ); mesh->setBoundingBox( meshbox );
} }
...@@ -936,7 +933,6 @@ IAnimatedMesh * CMeshManipulator::createAnimatedMesh(scene::IMesh* mesh,scene::E ...@@ -936,7 +933,6 @@ IAnimatedMesh * CMeshManipulator::createAnimatedMesh(scene::IMesh* mesh,scene::E
//mesh->drop (); //mesh->drop ();
return animatedMesh; return animatedMesh;
} }
......
...@@ -12,7 +12,7 @@ namespace irr ...@@ -12,7 +12,7 @@ namespace irr
namespace scene namespace scene
{ {
//! An interface for easily manipulate meshes. //! An interface for easy manipulation of meshes.
/** Scale, set alpha value, flip surfaces, and so on. This exists for fixing problems /** Scale, set alpha value, flip surfaces, and so on. This exists for fixing problems
with wrong imported or exported meshes quickly after loading. It is not intended for doing mesh with wrong imported or exported meshes quickly after loading. It is not intended for doing mesh
modifications and/or animations during runtime. modifications and/or animations during runtime.
......
...@@ -98,7 +98,7 @@ IAnimatedMesh* COgreMeshFileLoader::createMesh(io::IReadFile* file) ...@@ -98,7 +98,7 @@ IAnimatedMesh* COgreMeshFileLoader::createMesh(io::IReadFile* file)
return 0; return 0;
ChunkData data; ChunkData data;
readString(file, data, Version); readString(file, data, Version);
if (Version != "[MeshSerializer_v1.30]") if ((Version != "[MeshSerializer_v1.30]") && (Version != "[MeshSerializer_v1.40]"))
return 0; return 0;
clearMeshes(); clearMeshes();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment